/* claude-smith — UI in the style of claude.ai (warm light + dark) */

:root {
  /* Light theme (default) — warm "paper" palette */
  --bg:            #f4f3ee;
  --surface:       #ffffff;
  --surface-2:     #faf9f5;
  --surface-hover: #f2f0e9;
  --fg:            #21201c;
  --fg-soft:       #3d3b35;
  --muted:         #76746c;
  --border:        #e7e4da;
  --border-strong: #d8d4c8;
  --border-hover:  #b8b2a3;
  --input-bg:      #fbfaf6;
  --input-border:  #d4cfc2;
  --accent:        #c15f3c;   /* Claude clay */
  --accent-hover:  #a94e2f;
  --accent-soft:   #f6e9e3;
  --on-accent:     #ffffff;
  --danger:        #b3361f;
  --danger-soft:   #f8e3df;
  --success:       #3f7d4e;
  --success-soft:  #e4f0e6;
  --warn:          #9a6a16;
  --warn-soft:     #f6ecd6;
  --info-soft:     #e6eef3;
  --term-bg:       #1c1b19;
  --shadow:        0 1px 2px rgba(34, 32, 28, .05), 0 4px 16px rgba(34, 32, 28, .04);
  --radius:        12px;
  --radius-sm:     8px;
  --serif: "Tiempos", ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --bg:            #1c1b19;
  --surface:       #262421;
  --surface-2:     #211f1d;
  --surface-hover: #302d29;
  --fg:            #f3f1ea;
  --fg-soft:       #d9d6cd;
  --muted:         #a3a097;
  --border:        #38352f;
  --border-strong: #46423b;
  --border-hover:  #5d574d;
  --input-bg:      #1e1c1a;
  --input-border:  #47433b;
  --accent:        #d97757;   /* lighter clay for dark */
  --accent-hover:  #e58c6f;
  --accent-soft:   #3a2a22;
  --on-accent:     #1c1b19;
  --danger:        #e5806c;
  --danger-soft:   #3a2622;
  --success:       #79c489;
  --success-soft:  #233026;
  --warn:          #d8a755;
  --warn-soft:     #332a18;
  --info-soft:     #1f2b31;
  --term-bg:       #131210;
  --shadow:        0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- nav ---------- */
.nav {
  display: flex;
  gap: .35rem;
  align-items: center;
  padding: .7rem 1.5rem;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav a { color: var(--fg-soft); text-decoration: none; }
.nav a:not(.brand) {
  padding: .35rem .7rem;
  border-radius: 999px;
  font-size: .92rem;
  transition: background .15s ease, color .15s ease;
}
.nav a:not(.brand):hover { background: var(--surface-hover); color: var(--fg); }
.nav a.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.18rem;
  color: var(--fg);
  margin-right: .6rem;
  letter-spacing: -.01em;
}
.nav a.brand .brand-logo {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: block;
}
.nav .version {
  color: var(--muted);
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  padding: .08rem .4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-right: .4rem;
}
.nav .spacer { flex: 1; }
.nav .muted { color: var(--muted); font-size: .88rem; }
.nav .link {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font: inherit; font-size: .88rem; padding: .35rem .7rem; border-radius: 999px;
}
.nav .link:hover { background: var(--surface-hover); color: var(--fg); }

/* theme toggle */
.theme-toggle {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg-soft);
  cursor: pointer;
  padding: 0;
  transition: background .15s ease, border-color .15s ease;
}
.theme-toggle:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
.floating { position: fixed; top: 1.25rem; right: 1.25rem; z-index: 50; }
.floating .theme-toggle { box-shadow: var(--shadow); }

/* ---------- layout ---------- */
.container { max-width: 1080px; margin: 2rem auto; padding: 0 1.5rem; }

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.9rem;
  letter-spacing: -.02em;
  margin: 0 0 1.25rem;
  line-height: 1.2;
}
h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: -.01em;
  margin: 0 0 .85rem;
}
h1 .muted { font-family: var(--sans); font-weight: 400; font-size: 1rem; }

section { margin: 2rem 0; }

/* ---------- tables / cards ---------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-top: 1.5rem;
}
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
thead th {
  background: var(--surface-2);
  font-size: .74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--surface-hover); }
td code, code {
  font-family: var(--mono);
  font-size: .82em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: .1rem .4rem;
  border-radius: 6px;
}

.muted { color: var(--muted); }

/* ---------- flashes ---------- */
.flash, .error {
  padding: .7rem 1rem;
  margin-bottom: 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .92rem;
}
.flash { background: var(--info-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }

/* ---------- forms ---------- */
.form-card {
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.6rem 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.form-card > label:first-of-type { margin-top: 0; }
.form-card > button[type=submit] { margin-top: 1.6rem; }
.form-card + form { margin-top: 1rem; }
/* compact create-form for admin pages (few fields) */
.form-card.narrow { max-width: 420px; }

/* inline membership "chips" (admin users) */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem; margin: 0;
  padding: .15rem .25rem .15rem .6rem; border-radius: 999px;
  background: var(--surface-hover); border: 1px solid var(--border); font-size: .82rem;
}
.chip button { background: transparent; border: 0; color: var(--muted); padding: 0 .35rem; margin: 0; box-shadow: none; cursor: pointer; line-height: 1; }
.chip button:hover { color: var(--danger); background: transparent; }
/* a row of action buttons/forms placed side by side (e.g. Edit + Run now) */
.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; }
.actions form { margin: 0; }
.actions form button, .actions > .button { margin: 0; }
.inline-add { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }
.inline-add select { width: auto; min-width: 8rem; }
.inline-add button { margin: 0; }

form label { display: block; margin: 1.15rem 0 .4rem; font-size: .82rem; font-weight: 600; letter-spacing: .01em; color: var(--fg-soft); }
form > p.muted, .form-card p.muted { font-size: .82rem; margin: .4rem 0 0; }
form label.checkbox { display: flex; gap: .55rem; align-items: center; font-weight: 500; font-size: .92rem; color: var(--fg); margin-top: 1.15rem; }
form label.checkbox input { width: auto; }

/* a label-styled caption above a non-input control (e.g. a checkbox list) */
.field-label { display: block; margin: 1.15rem 0 .4rem; font-size: .82rem; font-weight: 600; letter-spacing: .01em; color: var(--fg-soft); }
/* a scrollable list of checkboxes (channel → routines) */
.checkbox-list {
  display: flex; flex-direction: column; gap: .1rem;
  max-height: 11rem; overflow-y: auto;
  padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface);
}
form label.checkbox-row {
  display: flex; gap: .55rem; align-items: center; margin: 0; padding: .2rem 0;
  font-size: .9rem; font-weight: 500; letter-spacing: 0; color: var(--fg); cursor: pointer;
}
form label.checkbox-row input { width: auto; margin: 0; }

/* Match every text-like input — including <input> with no type attribute
   (defaults to text), which a bare [type=text] selector would miss. */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=submit]):not([type=button]):not([type=hidden]),
select, textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: .6rem .8rem;
  border: 1.5px solid var(--input-border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--fg);
  font-family: inherit;
  font-size: .95rem;
  line-height: 1.45;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  appearance: none;
  -webkit-appearance: none;
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=submit]):not([type=button]):not([type=hidden]):hover,
select:hover, textarea:hover {
  border-color: var(--border-hover);
  background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .65; }
textarea { font-family: var(--mono); font-size: .88rem; line-height: 1.55; resize: vertical; min-height: 130px; }

/* custom dropdown chevron */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2376746c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}
input[type=time] { cursor: text; }
input[type=checkbox] { width: 1.05rem; height: 1.05rem; min-height: 0; accent-color: var(--accent); cursor: pointer; }

/* range slider (e.g. timeout) */
output { font-weight: 600; color: var(--accent); }
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  max-width: 24rem;
  height: 6px;
  padding: 0;
  margin: .6rem 0;
  border: 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow);
}
input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
}
input[type=range]:focus { outline: none; box-shadow: none; }
input[type=range]:focus::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }

/* ---------- buttons ---------- */
button, a.button {
  display: inline-block;
  padding: .5rem 1rem;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s ease, transform .05s ease;
}
button:hover, a.button:hover { background: var(--accent-hover); text-decoration: none; }
button:active, a.button:active { transform: translateY(1px); }
button.danger, a.button.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
button.danger:hover, a.button.danger:hover { background: var(--danger-soft); }
/* secondary / outline buttons used inside tables (e.g. "Run") */
table button, table a.button {
  background: var(--surface);
  color: var(--fg-soft);
  border-color: var(--border-strong);
  padding: .35rem .8rem;
  font-size: .85rem;
}
table button:hover, table a.button:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
/* row of inline buttons that should add a "×" remove style */
fieldset.vars button[type=button] {
  background: var(--surface); color: var(--muted); border: 1px solid var(--border-strong);
  padding: .3rem .7rem;
}
fieldset.vars button[type=button]:hover { background: var(--surface-hover); color: var(--fg); }

a.cancel { margin-left: 1rem; color: var(--muted); }
a.cancel:hover { color: var(--fg); }

/* ---------- login ---------- */
.login-box {
  max-width: 380px;
  margin: 8vh auto 0;
  background: var(--surface);
  padding: 2.25rem 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-box h1 { text-align: center; margin-bottom: 1.5rem; }
.login-box form button { width: 100%; margin-top: 1.25rem; padding: .6rem; }
.login-box .muted { display: block; text-align: center; margin-top: 1.25rem; font-size: .88rem; }

/* ---------- code / detail ---------- */
.code, pre.code {
  background: var(--term-bg);
  color: #e8e6df;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  overflow: auto;
  font-family: var(--mono);
  font-size: .85rem;
  line-height: 1.55;
  border: 1px solid var(--border);
}

dl.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .55rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  box-shadow: var(--shadow);
}
dl.meta dt { color: var(--muted); font-size: .88rem; }
dl.meta dd { margin: 0; font-weight: 500; }

/* ---------- status pills ---------- */
[class^="status-"], [class*=" status-"] {
  display: inline-block;
  padding: .15rem .6rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid transparent;
}
.status-queued    { color: var(--muted);   background: var(--surface-2);   border-color: var(--border); }
.status-assigned  { color: var(--warn);     background: var(--warn-soft);    border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.status-running   { color: var(--accent);   background: var(--accent-soft);  border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.status-succeeded { color: var(--success);  background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.status-failed,
.status-timed_out,
.status-cancelled { color: var(--danger);   background: var(--danger-soft);  border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

/* ---------- terminal ---------- */
#terminal {
  background: var(--term-bg);
  padding: .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-height: 420px;
  box-shadow: var(--shadow);
}

/* ---------- fieldset ---------- */
fieldset.vars {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
  background: var(--surface-2);
}
fieldset.vars legend { padding: 0 .5rem; font-weight: 600; font-size: .9rem; }
fieldset.vars table { border: 0; box-shadow: none; background: transparent; margin-top: 0; }
fieldset.vars table thead th { background: transparent; }

/* page-level action row under an h1 */
h1 + p { margin-top: -.5rem; }

/* ---------- schedule widget ---------- */
.schedule {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1rem 1.15rem;
  margin-top: .35rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.schedule > select#sched_freq { width: 100%; max-width: 24rem; }
.schedule .sched-row {
  display: none;            /* toggled to flex by JS for the active frequency */
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem .65rem;
}
.schedule .sched-row span { color: var(--muted); font-size: .9rem; }
.schedule .sched-row select,
.schedule .sched-row input { width: auto; min-width: 0; }
.schedule .sched-num { width: 5.5rem; }
.schedule .sched-time { width: 9rem; }
.schedule .sched-row[data-when="advanced"] input {
  width: 100%; max-width: 24rem; font-family: var(--mono); font-size: .9rem;
}
.schedule .sched-hint { margin: .15rem 0 0; font-size: .82rem; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .container { margin: 1.25rem auto; padding: 0 1rem; }
  h1 { font-size: 1.6rem; }
  .nav { flex-wrap: wrap; gap: .25rem .35rem; padding: .6rem 1rem; }
  .nav .spacer { flex-basis: 100%; height: 0; }
  .nav .muted { display: none; }
  /* let wide tables scroll horizontally instead of overflowing the page */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  dl.meta { grid-template-columns: 1fr; gap: .15rem; }
  dl.meta dd { margin-bottom: .6rem; }
  .login-box { margin-top: 5vh; padding: 1.75rem 1.35rem; }
}
@media (max-width: 420px) {
  .schedule .sched-time { width: 100%; }
}
