:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f8f9ff;
  --border: #e6e8f2;
  --text: #1c2033;
  --text-soft: #5a6178;
  --primary: #5b5bf0;
  --primary-dark: #4848d6;
  --primary-soft: #ececfe;
  --success: #18a058;
  --success-soft: #e5f6ec;
  --warn: #c98a00;
  --warn-soft: #fbf2dc;
  --danger: #e0466e;
  --danger-soft: #fce7ed;
  --shadow: 0 6px 24px rgba(40, 44, 80, 0.08);
  --shadow-sm: 0 2px 8px rgba(40, 44, 80, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: 'Heebo', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

h1, h2, h3, .tab, button { font-family: 'Rubik', system-ui, sans-serif; }

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon {
  font-size: 26px;
  width: 50px; height: 50px;
  display: grid; place-items: center;
  background: var(--primary-soft);
  border-radius: 14px;
}
.brand h1 { font-size: 19px; margin: 0; font-weight: 600; }
.brand-sub { margin: 0; font-size: 12.5px; color: var(--text-soft); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 999px;
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge-muted { background: #eef0f7; color: var(--text-soft); }
.badge-live { background: var(--success-soft); color: var(--success); }
.badge-demo { background: var(--warn-soft); color: var(--warn); }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 4px;
  padding: 10px 28px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 83px; z-index: 19;
  overflow-x: auto;
}
.tab {
  border: none; background: none; cursor: pointer;
  padding: 11px 18px; font-size: 14.5px; font-weight: 500;
  color: var(--text-soft); border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0; white-space: nowrap; transition: .15s;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── View ── */
.view { max-width: 1080px; margin: 0 auto; padding: 28px; }
.page-head { margin-bottom: 22px; }
.page-head h2 { margin: 0 0 4px; font-size: 23px; }
.page-head p { margin: 0; color: var(--text-soft); font-size: 14px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.card + .card { margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Forms ── */
label { display: block; font-size: 13.5px; font-weight: 500; margin-bottom: 7px; color: var(--text); }
.field { margin-bottom: 16px; }
input[type=text], input[type=password], select, textarea {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14.5px; color: var(--text);
  background: var(--surface-2); transition: .15s; resize: vertical;
}
input[type=text]:focus, input[type=password]:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  background: #fff; box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { min-height: 90px; line-height: 1.6; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: .15s; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: #d3d7e8; }
.btn-soft { background: var(--primary-soft); color: var(--primary-dark); }
.btn-soft:hover:not(:disabled) { background: #e0e0fd; }
.btn-danger-ghost { background: var(--surface); color: var(--danger); border-color: var(--danger-soft); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Dropzone ── */
.dropzone {
  border: 2px dashed #cdd1e6; border-radius: var(--radius);
  background: var(--surface-2); text-align: center;
  padding: 44px 20px; cursor: pointer; transition: .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .dz-icon { font-size: 42px; }
.dropzone h3 { margin: 12px 0 4px; font-size: 17px; }
.dropzone p { margin: 0; color: var(--text-soft); font-size: 13.5px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 8px 14px;
  background: var(--primary-soft); color: var(--primary-dark);
  border-radius: 999px; font-size: 13.5px; font-weight: 500;
}

/* ── Status line ── */
.statusline {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; margin-top: 16px;
}
.statusline.working { background: var(--primary-soft); color: var(--primary-dark); }
.statusline.error { background: var(--danger-soft); color: var(--danger); }
.statusline.ok { background: var(--success-soft); color: var(--success); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Output / transcript blocks ── */
.block-label {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.block-label h3 { margin: 0; font-size: 15.5px; }
.output-box {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
  white-space: pre-wrap; font-size: 14.5px; line-height: 1.7;
}
.summary-item { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 14px; overflow: hidden; }
.summary-item .si-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.summary-item .si-instr { font-size: 13px; color: var(--text-soft); font-weight: 500; }
.summary-item .si-body { padding: 14px; white-space: pre-wrap; font-size: 14.5px; line-height: 1.7; }

/* ── List (history / templates) ── */
.list { display: flex; flex-direction: column; gap: 12px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 15px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: .15s;
}
.list-item:hover { border-color: #d3d7e8; box-shadow: var(--shadow-sm); }
.list-item .li-main { min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 15px; margin: 0 0 2px; }
.list-item .li-meta { font-size: 12.5px; color: var(--text-soft); }
.li-actions { display: flex; gap: 8px; flex-shrink: 0; }

.pill { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.pill-done { background: var(--success-soft); color: var(--success); }
.pill-error { background: var(--danger-soft); color: var(--danger); }
.pill-working { background: var(--primary-soft); color: var(--primary-dark); }
.pill-default { background: #eef0f7; color: var(--text-soft); }
.pill-demo { background: var(--warn-soft); color: var(--warn); }

.empty { text-align: center; padding: 50px 20px; color: var(--text-soft); }
.empty .em-icon { font-size: 40px; opacity: .5; }

.search { margin-bottom: 16px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 22px;
  border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
  z-index: 50; animation: rise .2s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }

.hint { font-size: 12.5px; color: var(--text-soft); margin-top: 6px; }
.mt-0 { margin-top: 0; }

/* ── danger filled button ── */
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c93862; }

/* ── steps hint (upload) ── */
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text-soft);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 14px;
}
.step .step-num {
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 600;
}

/* ── helper text under section titles ── */
.section-hint { font-size: 13px; color: var(--text-soft); margin: -2px 0 14px; }

/* ── login + account ── */
.topbar-right { display: flex; align-items: center; gap: 12px; }
.login-wrap { min-height: 64vh; display: grid; place-items: center; }
.login-card { max-width: 380px; width: 100%; text-align: center; }
.login-card h2 { margin: 8px 0 2px; }
.login-card .field { text-align: right; }
.login-icon {
  font-size: 36px; width: 72px; height: 72px; margin: 0 auto 6px;
  display: grid; place-items: center; background: var(--primary-soft); border-radius: 18px;
}
.account { position: relative; }
.account-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; font-size: 13.5px; font-weight: 500; cursor: pointer;
  color: var(--text); font-family: 'Rubik', sans-serif; white-space: nowrap;
}
.account-btn:hover { background: var(--surface-2); border-color: #d3d7e8; }
.account-menu {
  position: absolute; left: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); overflow: hidden; z-index: 30; min-width: 170px;
}
.account-menu button {
  display: block; width: 100%; text-align: right; padding: 11px 16px;
  border: none; background: none; cursor: pointer; font-size: 14px; color: var(--text);
  font-family: 'Heebo', sans-serif;
}
.account-menu button:hover { background: var(--surface-2); }

/* ── confirm modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(28, 32, 51, 0.5); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px; max-width: 400px; width: 100%;
  box-shadow: var(--shadow); animation: rise 0.18s ease;
}
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 20px; color: var(--text-soft); font-size: 14.5px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ── Mobile ── */
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 16px; position: static; }
  .brand h1 { font-size: 17px; }
  .brand-icon { width: 44px; height: 44px; font-size: 22px; }
  .badge { font-size: 12px; }

  .tabs { padding: 6px 10px 0; position: sticky; top: 0; gap: 2px; }
  .tab { padding: 10px 12px; font-size: 13.5px; }

  .view { padding: 16px; }
  .card { padding: 16px; border-radius: 14px; }
  .card + .card { margin-top: 14px; }
  .page-head h2 { font-size: 20px; }

  /* full-width, finger-friendly buttons */
  .btn { padding: 12px 16px; }
  .btn-sm { padding: 9px 12px; font-size: 13px; }

  /* stack list rows and their actions */
  .list-item { flex-direction: column; align-items: stretch; gap: 12px; }
  .li-actions { flex-wrap: wrap; }
  .li-actions .btn { flex: 1; min-width: 72px; }

  .summary-item .si-head { flex-direction: column; align-items: stretch; gap: 10px; }

  .dropzone { padding: 32px 16px; }
  .dropzone h3 { font-size: 16px; }

  .steps { gap: 6px; }
  .step { font-size: 12px; padding: 6px 11px; }
}

@media print {
  .topbar, .tabs, .li-actions, .btn-row, #toast { display: none !important; }
  body { background: #fff; }
  .view { padding: 0; }
}
