:root {
  --navy: #102f49;
  --navy-2: #174866;
  --teal: #18a1a8;
  --teal-dark: #08777d;
  --gold: #f1b84b;
  --ink: #172433;
  --muted: #637384;
  --line: #d9e2e9;
  --soft: #f3f7f9;
  --white: #fff;
  --good: #198754;
  --warn: #c97912;
  --bad: #bd3944;
  --shadow: 0 12px 30px rgba(20, 48, 69, .09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: #edf3f6;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

.app-header {
  min-height: 76px;
  padding: 12px clamp(18px, 4vw, 54px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  background: linear-gradient(105deg, #0c2b45 0%, #164a69 67%, #126b77 100%);
  box-shadow: 0 4px 16px rgba(7, 32, 49, .2);
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center;
  border: 2px solid rgba(255,255,255,.9); border-radius: 14px;
  font-family: Georgia, serif; font-size: 30px; font-weight: 700; font-style: italic;
  transform: rotate(-2deg);
}
.brand-mark span { font-size: 18px; margin: 14px 0 0 -6px; color: #69d1d5; }
.brand-name { font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em; }
.brand-name em { color: #68d0d5; font-size: .7em; font-style: normal; vertical-align: top; }
.brand-section { font-size: .78rem; color: #cfe0ea; letter-spacing: .08em; text-transform: uppercase; }
.version { color: #d6e4ec; font-size: .82rem; }

.app-shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 26px clamp(14px, 2.8vw, 42px) 34px;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(340px, .75fr);
  gap: 22px;
  align-items: start;
}

.workspace { display: grid; gap: 20px; min-width: 0; }
.panel, .coach-panel {
  background: var(--white); border: 1px solid rgba(15, 54, 80, .09);
  border-radius: 18px; box-shadow: var(--shadow);
}
.panel { padding: clamp(20px, 3vw, 30px); }
.panel-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.panel-heading h1, .panel-heading h2, .results-heading h2, .coach-header h2 {
  margin: 0; color: var(--navy); font-size: 1.25rem; letter-spacing: -.02em;
}
.panel-heading p, .results-heading p, .detail-heading p { margin: 3px 0 0; color: var(--muted); font-size: .9rem; }
.step-number {
  flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px; color: white; background: var(--teal); font-weight: 800;
}

.file-picker {
  min-height: 88px; padding: 16px 18px; border: 1.5px dashed #9fb5c4; border-radius: 14px;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  background: #f8fbfc; cursor: pointer; transition: .18s ease;
}
.file-picker:hover, .file-picker.dragover { border-color: var(--teal); background: #f0fbfb; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: #dff3f4; color: var(--teal-dark); font-size: 1.45rem; }
.file-copy { min-width: 0; display: flex; flex-direction: column; }
.file-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-copy small { color: var(--muted); }
.browse-button { padding: 8px 14px; border: 1px solid #b7c7d1; border-radius: 9px; color: var(--navy); background: white; font-weight: 700; }
.status-line { margin-top: 10px; font-size: .86rem; }
.muted { color: var(--muted); }
.status-line.success { color: var(--good); }
.status-line.error { color: var(--bad); }

.settings-grid { display: grid; grid-template-columns: 1.7fr 1fr 1fr; gap: 14px; margin-top: 20px; }
.settings-grid label > span, .coach-input label { display: block; margin-bottom: 6px; color: #45596b; font-size: .79rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
select, input[type="number"], .coach-input input {
  width: 100%; height: 45px; border: 1px solid #bdccd5; border-radius: 10px; color: var(--ink); background: white; padding: 0 12px; outline: none;
}
select:focus, input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(24, 161, 168, .13); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 48px; }
.input-suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .8rem; font-weight: 700; }

.recorder { border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: var(--soft); }
.record-display { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.record-state { display: flex; align-items: center; gap: 9px; }
.record-display time { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--navy); font-size: 1.1rem; }
.record-dot { width: 11px; height: 11px; border-radius: 50%; background: #9eabb3; }
.record-dot.active { background: #e13e48; box-shadow: 0 0 0 6px rgba(225,62,72,.12); animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.meter { height: 7px; margin: 15px 0 17px; overflow: hidden; border-radius: 9px; background: #dce5ea; }
.meter-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--gold), #dc4751); transition: width .06s linear; }
.record-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.button { min-height: 42px; border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 800; }
.record-button { color: white; background: #c93440; }
.record-button:hover { background: #ad2631; }
.secondary { color: var(--navy); background: white; border: 1px solid #b9c8d1; }
.secondary:hover:not(:disabled) { background: #f4f8fa; }
.text-button { background: transparent; color: var(--teal-dark); }
.compact { min-height: 36px; padding: 7px 12px; font-size: .86rem; }
.analyze-button { width: 100%; margin-top: 15px; color: white; background: linear-gradient(95deg, var(--teal-dark), var(--teal)); display: flex; justify-content: center; align-items: center; gap: 12px; font-size: 1rem; }
.analyze-button:hover:not(:disabled) { filter: brightness(.94); }

.results-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.eyebrow { display: block; color: var(--teal-dark); font-size: .73rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.empty-state { padding: 46px 15px 30px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--navy); font-size: 1.05rem; }
.empty-state p { margin: 5px auto; max-width: 480px; }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 16px; color: var(--teal-dark); background: #e5f5f6; font-size: 1.8rem; }
.analysis-loading { padding: 50px 20px; text-align: center; color: var(--muted); }
.analysis-loading strong { display: block; color: var(--navy); }
.analysis-loading p { margin: 4px; }
.spinner { width: 34px; height: 34px; margin: 0 auto 13px; border: 4px solid #dce9ec; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.summary-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 20px 0 14px; }
.summary-card { min-width: 0; padding: 14px; border-radius: 12px; background: var(--soft); border-left: 4px solid var(--teal); }
.summary-card span { display: block; color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.summary-card strong { display: block; margin-top: 3px; color: var(--navy); font-size: 1.28rem; line-height: 1.2; }
.summary-card small { color: var(--muted); font-size: .74rem; }
.feedback-card { border: 1px solid #cfe3e5; border-radius: 13px; padding: 15px 17px; background: #f0faf9; }
.feedback-card h3 { margin: 0 0 5px; color: var(--navy); font-size: .96rem; }
.feedback-card p { margin: 3px 0; color: #385361; }
.detail-section { margin-top: 22px; }
.detail-heading { display: flex; justify-content: space-between; align-items: end; gap: 15px; margin-bottom: 10px; }
.detail-heading h3 { margin: 0; color: var(--navy); font-size: 1rem; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; color: var(--muted); font-size: .76rem; }
.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; }
.legend-good { background: var(--good); } .legend-warn { background: var(--warn); } .legend-miss { background: var(--bad); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; white-space: nowrap; }
th { padding: 10px 11px; color: #4b6172; background: #edf3f6; text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
td { padding: 10px 11px; border-top: 1px solid #e3eaee; }
tr:hover td { background: #f8fbfc; }
.pill { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-weight: 800; font-size: .74rem; }
.pill.good { color: #12653e; background: #dff4e9; }
.pill.warn { color: #89520d; background: #fff0d7; }
.pill.bad { color: #8d2630; background: #fbe3e5; }
.pill.neutral { color: #526674; background: #e9eff2; }
.diagnostics { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; color: var(--muted); font-size: .84rem; }
.diagnostics summary { cursor: pointer; color: var(--navy); font-weight: 800; }
.diagnostics dl { display: grid; grid-template-columns: max-content 1fr; gap: 5px 12px; }
.diagnostics dt { font-weight: 700; } .diagnostics dd { margin: 0; }

.coach-panel { position: sticky; top: 20px; min-height: 620px; overflow: hidden; display: flex; flex-direction: column; }
.coach-header { display: flex; gap: 12px; align-items: center; padding: 19px 20px; color: white; background: var(--navy); }
.coach-header h2 { color: white; font-size: 1.04rem; }
.coach-header p { margin: 2px 0 0; color: #b9cbd6; font-size: .77rem; }
.coach-avatar { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: var(--navy); background: #66d1d4; font-weight: 900; }
.offline-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #93a5b0; }
.coach-conversation { flex: 1; padding: 20px; background: linear-gradient(#f8fbfc, #f2f7f8); }
.coach-message { width: 92%; padding: 14px 15px; border: 1px solid #dae5ea; border-radius: 6px 15px 15px 15px; background: white; box-shadow: 0 5px 14px rgba(20,48,69,.06); }
.coach-message strong { color: var(--teal-dark); font-size: .78rem; }
.coach-message p { margin: 5px 0 0; font-size: .9rem; color: #3d5362; }
.coach-placeholder { margin: 28px 8px; padding: 17px; border: 1px dashed #b7cbd4; border-radius: 13px; text-align: center; color: var(--muted); }
.coach-placeholder span { color: var(--teal); font-size: 1.3rem; }
.coach-placeholder p { margin: 4px 0; font-size: .84rem; }
.coach-input { padding: 16px; border-top: 1px solid var(--line); background: white; }
.coach-input-row { display: grid; grid-template-columns: 1fr 42px; gap: 8px; }
.coach-input-row button { border: 0; border-radius: 10px; color: white; background: var(--teal); font-weight: 900; }

footer { padding: 0 18px 25px; text-align: center; color: #788894; font-size: .75rem; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 1fr; }
  .coach-panel { position: static; min-height: 430px; }
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 650px) {
  .version { display: none; }
  .app-header { padding: 10px 14px; }
  .brand-mark { width: 42px; height: 42px; }
  .app-shell { padding: 14px 10px 26px; gap: 14px; }
  .panel { padding: 18px 14px; border-radius: 14px; }
  .settings-grid { grid-template-columns: 1fr; }
  .file-picker { grid-template-columns: auto minmax(0,1fr); }
  .browse-button { display: none; }
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .detail-heading { align-items: flex-start; flex-direction: column; }
  .legend { justify-content: flex-start; }
}
