:root {
  color-scheme: light dark;
  --page: #f3f5f2;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --surface-raised: rgba(255, 255, 255, 0.94);
  --ink: #17221f;
  --muted: #64716d;
  --line: #d8dfdb;
  --line-strong: #b8c4bf;
  --accent: #087866;
  --accent-dark: #07594d;
  --accent-soft: #daf2eb;
  --warning: #8b5d10;
  --warning-soft: #fff3d6;
  --danger: #a2343d;
  --danger-soft: #fde9e9;
  --info: #275f91;
  --info-soft: #e7f2fb;
  --shadow: 0 20px 60px rgba(28, 52, 45, 0.10);
  --shadow-small: 0 8px 24px rgba(28, 52, 45, 0.07);
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--page); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(17, 142, 119, 0.11), transparent 28rem),
    radial-gradient(circle at 92% 88%, rgba(190, 139, 58, 0.10), transparent 30rem),
    var(--page);
}

[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--accent-dark); }
code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
:focus-visible { outline: 3px solid #2e9b87; outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  transform: translateY(-150%);
  border-radius: 10px;
  color: #fff;
  background: var(--accent-dark);
}
.skip-link:focus { transform: translateY(0); }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  min-height: 78px;
  align-items: center;
  gap: 24px;
  padding: 12px clamp(16px, 3vw, 42px);
  border-bottom: 1px solid rgba(122, 140, 133, 0.24);
  background: rgba(249, 251, 249, 0.88);
  backdrop-filter: blur(18px);
}

.brand { display: flex; min-width: 0; align-items: center; gap: 12px; }
.brand__mark {
  display: grid;
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #138c77, #07594d);
  box-shadow: 0 9px 22px rgba(8, 120, 102, 0.22);
  font-family: Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
}
.brand h1 { margin: 0; font-size: 1.16rem; letter-spacing: -0.025em; }
.brand .eyebrow { margin-bottom: 2px; font-size: 0.65rem; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.badge {
  display: inline-flex;
  width: max-content;
  align-items: center;
  min-height: 25px;
  padding: 3px 9px;
  border: 1px solid #bfcbc7;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.03em;
}

.service-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 0.82rem; }
.service-status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #b98a38;
  box-shadow: 0 0 0 4px rgba(185, 138, 56, 0.14);
}
.service-status--ready .service-status__dot { background: #148165; box-shadow: 0 0 0 4px rgba(20, 129, 101, 0.14); }
.service-status--error .service-status__dot { background: #bb414b; box-shadow: 0 0 0 4px rgba(187, 65, 75, 0.14); }
.service-status--loading .service-status__dot { animation: pulse 1.2s ease-in-out infinite; }

.account { display: flex; align-items: center; gap: 10px; }
.account__name { max-width: 18rem; overflow: hidden; font-size: 0.8rem; font-weight: 760; text-overflow: ellipsis; white-space: nowrap; }

.center-state, .login-view {
  display: grid;
  min-height: calc(100vh - 78px);
  padding: 40px 18px;
  place-items: center;
  align-content: center;
  text-align: center;
}
.center-state h2 { margin: 18px 0 8px; font-family: Georgia, serif; font-size: clamp(1.8rem, 4vw, 2.7rem); font-weight: 560; }
.center-state p { max-width: 610px; margin: 0 0 22px; color: var(--muted); line-height: 1.6; }
.loader { width: 38px; height: 38px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.state-icon { display: grid; width: 54px; height: 54px; place-items: center; border-radius: 50%; font-size: 1.5rem; font-weight: 850; }
.state-icon--warning { color: var(--warning); background: var(--warning-soft); }

.login-card {
  display: grid;
  width: min(100%, 430px);
  gap: 11px;
  padding: clamp(28px, 5vw, 44px);
  border: 1px solid rgba(115, 138, 129, 0.28);
  border-radius: 24px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  text-align: left;
}
.login-card h2 { margin: 0; font-family: Georgia, serif; font-size: 2rem; font-weight: 560; }
.login-card .muted { margin: 0 0 12px; }

label { display: block; margin-bottom: 6px; font-size: 0.79rem; font-weight: 760; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface);
}
textarea { min-height: 104px; resize: vertical; line-height: 1.5; }
input:invalid:not(:placeholder-shown), textarea:invalid:not(:placeholder-shown) { border-color: #c56b72; }
.field-hint { margin: -5px 0 4px; color: var(--muted); font-size: 0.74rem; line-height: 1.45; }

.studio { display: grid; grid-template-columns: minmax(250px, 310px) minmax(0, 1fr); min-height: calc(100vh - 78px); }
.sidebar {
  position: sticky;
  top: 78px;
  display: flex;
  height: calc(100vh - 78px);
  padding: 28px 18px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(248, 250, 248, 0.75);
  flex-direction: column;
  gap: 18px;
}
.sidebar__header, .panel__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.sidebar h2, .panel h2, .uncertain-panel h2, .overview h2 { margin: 0; font-family: Georgia, serif; font-weight: 560; letter-spacing: -0.02em; }
.sidebar h2 { font-size: 1.7rem; }

.workspace { display: grid; width: min(100%, 1180px); margin: 0 auto; padding: 34px clamp(18px, 4vw, 52px) 70px; align-content: start; gap: 22px; }
.overview, .panel, .uncertain-panel {
  padding: clamp(21px, 3vw, 31px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-small);
}
.overview { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 30px; }
.overview h2 { font-size: clamp(1.8rem, 3vw, 2.5rem); }
.overview > div > p:last-child { max-width: 680px; margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(95px, 1fr)); gap: 9px; margin: 0; }
.summary-grid div { min-width: 95px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.summary-grid dt { color: var(--muted); font-size: 0.7rem; }
.summary-grid dd { margin: 4px 0 0; font-size: 1.35rem; font-weight: 800; }

.panel h2 { font-size: 1.75rem; }
.panel h3 { margin: 0 0 5px; font-size: 1rem; }
.muted { color: var(--muted); }
.inline-state, .empty-state { margin: 18px 0 0; color: var(--muted); line-height: 1.5; }
.empty-state { padding: 18px; border: 1px dashed var(--line-strong); border-radius: 13px; text-align: center; }

.button, .icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 700;
}
.button { padding: 9px 15px; }
.button:disabled, .icon-button:disabled { cursor: wait; opacity: 0.56; }
.button--primary { color: #fff; background: var(--accent); }
.button--primary:hover:not(:disabled) { background: var(--accent-dark); }
.button--secondary { border-color: var(--line-strong); background: var(--surface); }
.button--secondary:hover:not(:disabled) { border-color: #879a92; }
.button--quiet { min-height: 36px; padding: 6px 10px; border-color: var(--line); background: transparent; }
.button--warning { color: #4f3508; background: #f3c96b; }
.button--danger { color: #fff; background: var(--danger); }
.icon-button { display: grid; width: 40px; padding: 0; place-items: center; border-color: var(--line); background: transparent; font-size: 1.2rem; }
.button-row, .form-actions, .dialog__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.project-list, .job-list { margin: 0; padding: 0; list-style: none; }
.project-list { display: grid; gap: 8px; }
.project-button {
  display: grid;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.project-button:hover { background: var(--surface); }
.project-button[aria-current="true"] { border-color: #8fc7bb; background: var(--accent-soft); }
.project-button strong { overflow-wrap: anywhere; font-size: 0.88rem; }
.project-button span { margin-top: 4px; color: var(--muted); font-size: 0.7rem; }

.form-grid { display: grid; max-width: 760px; margin-top: 24px; }
.form-grid > input, .form-grid > select, .form-grid > textarea { margin-bottom: 16px; }
.form-grid__split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.form-actions { margin-top: 4px; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 20px; margin: 20px 0 0; }
.detail-grid div { min-width: 0; padding: 11px 0; border-bottom: 1px solid var(--line); }
.detail-grid dt { color: var(--muted); font-size: 0.72rem; }
.detail-grid dd { margin: 4px 0 0; overflow-wrap: anywhere; font-size: 0.86rem; font-weight: 680; }
.action-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 22px; padding: 17px; border-radius: 14px; background: var(--surface-soft); }
.action-card p { margin: 0; color: var(--muted); font-size: 0.84rem; line-height: 1.5; }

.jobs-panel { min-height: 220px; }
.job-list { display: grid; gap: 10px; margin-top: 18px; }
.job-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.job-card__main { min-width: 0; }
.job-card__title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.job-card__title strong { overflow-wrap: anywhere; }
.job-card__meta { margin: 7px 0 0; color: var(--muted); font-size: 0.72rem; line-height: 1.45; }
.job-card__actions { display: flex; align-items: center; gap: 8px; }
.state-label { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; font-size: 0.69rem; font-weight: 780; }
.state-label::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.state-label--active { color: #216590; background: #e2f2fc; }
.state-label--success { color: #157158; background: #def3eb; }
.state-label--warning { color: #85580d; background: #fff0ca; }
.state-label--danger { color: #9c333c; background: #fbe4e5; }
.state-label--neutral { color: #566460; background: #e8edeb; }

.alert { margin: 0; padding: 13px 15px; border: 1px solid; border-radius: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.alert--danger { border-color: #edb8bc; color: var(--danger); background: var(--danger-soft); }
.alert--info { border-color: #b7d7ee; color: var(--info); background: var(--info-soft); }
.alert--warning { border-color: #e7ca8f; color: var(--warning); background: var(--warning-soft); }
.uncertain-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 24px; border-color: #dfbd77; background: var(--warning-soft); }
.uncertain-panel h2 { font-size: 1.45rem; }
.uncertain-panel p:last-child { margin: 7px 0 0; line-height: 1.5; }

.dialog { width: min(calc(100% - 24px), 610px); max-height: calc(100vh - 32px); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 20px; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.dialog--wide { width: min(calc(100% - 24px), 850px); }
.dialog::backdrop { background: rgba(9, 20, 17, 0.64); backdrop-filter: blur(3px); }
.dialog__body { padding: clamp(22px, 4vw, 34px); }
.dialog h2 { margin: 0; font-family: Georgia, serif; font-size: 1.8rem; font-weight: 560; }
.dialog p { line-height: 1.55; }
.dialog__actions { justify-content: flex-end; margin-top: 24px; }
.dialog__subject { padding: 12px; border-radius: 11px; background: var(--surface-soft); font-weight: 750; overflow-wrap: anywhere; }
.job-detail-section { margin-top: 20px; }
.job-detail-section h3 { margin: 0 0 10px; font-size: 1rem; }
.committed-project { margin-top: 17px; }
.recovery-card { margin-top: 17px; }
.log-tabs { display: flex; gap: 8px; margin-top: 18px; }
.log-output { max-height: 360px; margin: 12px 0 0; padding: 15px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #f3f6f4; font-size: 0.76rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-note { margin: 8px 0 0; color: var(--muted); font-size: 0.72rem; }

@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.8); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 920px) {
  .topbar { grid-template-columns: 1fr auto; gap: 10px 16px; }
  .service-status { grid-row: 2; }
  .account { grid-row: 2; justify-self: end; }
  .studio { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; max-height: 44vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .project-list { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .overview, .uncertain-panel { grid-template-columns: 1fr; }
  .summary-grid { width: 100%; }
}

@media (max-width: 620px) {
  .topbar { position: static; grid-template-columns: 1fr; padding: 12px 14px; }
  .brand .badge { display: none; }
  .service-status, .account { grid-row: auto; justify-self: start; }
  .workspace { padding: 22px 12px 48px; }
  .sidebar { top: 0; padding: 22px 14px; }
  .summary-grid, .form-grid__split, .detail-grid { grid-template-columns: 1fr; }
  .summary-grid div { display: flex; align-items: center; justify-content: space-between; }
  .summary-grid dd { margin: 0; }
  .action-card, .job-card { grid-template-columns: 1fr; align-items: stretch; }
  .action-card { flex-direction: column; align-items: stretch; }
  .job-card__actions { justify-content: flex-start; flex-wrap: wrap; }
  .dialog__actions { align-items: stretch; flex-direction: column; }
  .dialog__actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #101715;
    --surface: #18231f;
    --surface-soft: #1d2925;
    --surface-raised: rgba(24, 35, 31, 0.96);
    --ink: #edf4f1;
    --muted: #a4b1ad;
    --line: #34443e;
    --line-strong: #52665f;
    --accent: #66c9b5;
    --accent-dark: #8adbc9;
    --accent-soft: #153e35;
    --warning-soft: #3c2e12;
    --danger-soft: #3c2023;
    --info-soft: #172f43;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
    --shadow-small: 0 8px 24px rgba(0, 0, 0, 0.18);
  }
  body { background: radial-gradient(circle at 10% 0%, rgba(35, 145, 122, 0.18), transparent 28rem), var(--page); }
  .topbar { background: rgba(16, 23, 21, 0.90); }
  .sidebar { background: rgba(20, 30, 27, 0.82); }
  .state-label--active { color: #8dcbed; background: #183347; }
  .state-label--success { color: #7bd4b9; background: #17382f; }
  .state-label--warning { color: #efc978; background: #3c2e12; }
  .state-label--danger { color: #f1a1a8; background: #402125; }
  .state-label--neutral { color: #b5c2bd; background: #27332f; }
  .log-output { background: #111a17; }
}
