/* Kinvi — Audio Analysis internal tool
   Color/typography/spacing tokens follow the Iron Mind AI internal-tool
   dark theme (see docs/brandbook.md). */

:root {
  --bg: #0E0E0E;
  --bg-elevated: #161616;
  --bg-elevated-2: #1C1C1C;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #E8EAED;
  --text-muted: #A6A6A6;
  --text-faint: #888888;
  --accent: #E87C2E;
  --accent-hover: #F08C3E;
  --accent-dim: rgba(232, 124, 46, 0.12);

  --status-completed: #7FA88B;
  --status-failed: #B36A5E;
  --status-warning: #B08A4E;
  --status-neutral: #8A94A3;

  --radius: 8px;
  --radius-sm: 6px;
  --radius-pill: 999px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
}

* { box-sizing: border-box; }

/* Any element with a `display` override in this file still needs to fully
   disappear when the `hidden` attribute is set — otherwise a class rule
   like `display: flex` beats the UA stylesheet's `[hidden] { display: none }`
   and the element (e.g. the loading spinner) incorrectly shows by default. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* Header */
.app-header {
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.app-header-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.app-header-title h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.app-logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  align-self: center;
}

.app-subtitle {
  color: var(--text-faint);
  font-size: 13px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
}

.panel-desc {
  color: var(--text-faint);
  font-size: 12.5px;
  margin: 0 0 16px;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-header-row .panel-title {
  margin: 0;
}

/* Upload panel */
.drop-zone {
  display: block;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elevated-2);
  padding: 28px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  margin-bottom: 12px;
}

.drop-zone:hover,
.drop-zone:focus-within {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.drop-zone.drag-active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  color: var(--text-muted);
}

.drop-zone-icon {
  width: 22px;
  height: 22px;
  color: var(--text-faint);
}

.drop-zone-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drop-zone-primary {
  font-size: 13px;
  color: var(--text-muted);
}

.drop-zone-secondary {
  font-size: 11.5px;
  color: var(--text-faint);
}

.file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 12.5px;
  font-family: var(--font-mono);
  color: var(--text);
}

.file-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip-clear {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.file-chip-clear:hover {
  color: var(--accent-hover);
}

/* Buttons */
.btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #0E0E0E;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Status row / spinner */
.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Banners */
.banner {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.5;
}

.banner-error {
  background: rgba(179, 106, 94, 0.12);
  border: 1px solid rgba(179, 106, 94, 0.35);
  color: #D89C92;
}

.banner-warning {
  background: rgba(176, 138, 78, 0.12);
  border: 1px solid rgba(176, 138, 78, 0.35);
  color: #D9B87E;
}

/* Empty states */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}

.empty-state-sm {
  min-height: 80px;
}

/* Results */
#results-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.result-filename {
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.result-timestamp {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.card {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card-title {
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin: 0 0 12px;
}

/* Field grid (Style & Mood card) */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
}

.field-value {
  font-size: 13.5px;
  color: var(--text);
}

.field-value.empty {
  color: var(--text-faint);
  font-style: italic;
}

/* Energy meter */
.energy-meter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.energy-meter {
  flex: 1;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  overflow: hidden;
}

.energy-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: var(--radius-pill);
}

.energy-meter-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  min-width: 34px;
  text-align: right;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid;
}

.badge-yes {
  color: var(--status-completed);
  border-color: rgba(127, 168, 139, 0.35);
  background: rgba(127, 168, 139, 0.12);
}

.badge-no {
  color: var(--text-faint);
  border-color: var(--border);
  background: var(--bg-elevated);
}

/* Sub elements / tags */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.tag {
  background: var(--accent-dim);
  border: 1px solid rgba(232, 124, 46, 0.25);
  color: var(--accent-hover);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 11.5px;
}

/* Instrumentation list */
.instrument-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.instrument-item {
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.instrument-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.instrument-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.instrument-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Narrative arc */
.narrative-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Lyrics */
.lyrics-toggle-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.lyrics-toggle-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
}

.lyrics-toggle-btn.active {
  background: var(--accent-dim);
  border-color: rgba(232, 124, 46, 0.35);
  color: var(--accent-hover);
}

.lyrics-plain {
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.7;
}

.lyrics-line-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.lyrics-line {
  display: flex;
  gap: 10px;
  color: var(--text-muted);
}

.lyrics-line-time {
  color: var(--text-faint);
  flex-shrink: 0;
  min-width: 58px;
}

.lyrics-lang {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-bottom: 10px;
}

/* Metadata footer */
.meta-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* Journal */
.journal-panel {
  margin-top: 20px;
}

.journal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.journal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.journal-item + .journal-item {
  border-top: none;
}

.journal-item:hover {
  background: #202020;
  border-color: var(--border-strong);
}

.journal-item.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.journal-item-name {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal-item-time {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.journal-item-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.12s ease, color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.journal-item:hover .journal-item-delete,
.journal-item:focus-within .journal-item-delete,
.journal-item-delete:focus-visible {
  opacity: 1;
}

.journal-item-delete:hover {
  color: var(--status-failed);
  border-color: rgba(179, 106, 94, 0.35);
  background: rgba(179, 106, 94, 0.12);
}
