/* postwits.com — all styles.
 *
 * One dark theme, sized for reading long model output: the thinking and
 * answer boxes get a monospace face and generous line height, and everything
 * else stays out of their way.
 */

:root {
  --bg:            #14161a;
  --surface:       #1c1f26;
  --surface-high:  #232833;
  --border:        #2e343f;
  --text:          #e7eaf0;
  --text-dim:      #98a2b3;
  --primary:       #4c8dff;
  --primary-dark:  #3a72d8;
  --danger:        #e05555;
  --danger-dark:   #c33f3f;
  --good:          #46c07a;
  --warn:          #e0a83c;
  --radius:        14px;
  --gap:           18px;
}

* { box-sizing: border-box; }

/* `hidden` has to beat every layout rule below.
 *
 * The attribute works only through the browser's own `display: none`, which
 * sits at the very bottom of the cascade — so any rule here that sets a
 * display (`.shade { display: flex }`, `.measure-progress { display: flex }`)
 * silently wins, and the element stays on screen no matter what the markup
 * or the script says.  Stating it once here means `hidden` can be trusted
 * everywhere instead of being remembered class by class. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0 0 10px; font-weight: 600; line-height: 1.25; }
h2 { font-size: 17px; }
h3 { font-size: 14px; color: var(--text-dim); text-transform: uppercase;
     letter-spacing: .06em; }

code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* -- top bar -------------------------------------------------------------- */

.top-bar {
  display: flex; align-items: center; gap: var(--gap);
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  font-size: 20px; font-weight: 700; letter-spacing: -.02em;
  color: var(--text); text-decoration: none;
}
.nav { display: flex; gap: 6px; flex: 1; }
.nav-link {
  color: var(--text-dim); text-decoration: none;
  padding: 5px 11px; border-radius: 9px; font-size: 14px;
}
.nav-link:hover { background: var(--surface-high); color: var(--text); }
.nav-link.active { background: var(--surface-high); color: var(--text); }
.top-right { display: flex; align-items: center; gap: 12px; }
.who { color: var(--text-dim); font-size: 14px; }

/* -- cards and buttons ---------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.btn {
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer;
  background: var(--surface-high); color: var(--text);
  transition: background .12s ease, opacity .12s ease;
}
.btn:hover:not(:disabled) { background: #2c3240; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-dark); }
.btn-quiet { background: transparent; border-color: var(--border);
             color: var(--text-dim); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-high);
                                  color: var(--text); }
.btn-wide { width: 100%; }
.btn-small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }

/* -- forms ---------------------------------------------------------------- */

.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 5px;
}
input[type=text], input[type=password], input[type=search], textarea, select {
  width: 100%; font: inherit;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 11px;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary);
}

.error-box, .notice-box, .form-message {
  padding: 9px 12px; border-radius: 10px; font-size: 14px; margin: 0 0 14px;
}
.error-box { background: rgba(224,85,85,.14); color: #ff9d9d;
             border: 1px solid rgba(224,85,85,.35); }
.notice-box { background: rgba(76,141,255,.13); color: #a8c6ff;
              border: 1px solid rgba(76,141,255,.3); }
.form-message.good { background: rgba(70,192,122,.14); color: #8fe0b0;
                     border: 1px solid rgba(70,192,122,.35); }
.form-message.bad { background: rgba(224,85,85,.14); color: #ff9d9d;
                    border: 1px solid rgba(224,85,85,.35); }

/* -- login ---------------------------------------------------------------- */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 24px;
}
.login-card { width: 100%; max-width: 380px; }
.login-brand { font-size: 30px; text-align: center; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--text-dim); margin: 0 0 22px;
             font-size: 14px; }

/* -- front ---------------------------------------------------------------- */

.front-wrap { max-width: 640px; margin: 60px auto; padding: 0 20px; }
.front-card { text-align: center; padding: 40px 24px; }
.front-hello { font-size: 26px; font-weight: 600; margin: 0 0 6px; }
.front-sub { color: var(--text-dim); margin: 0 0 22px; }

/* -- admin layout --------------------------------------------------------- */

.admin-wrap {
  max-width: 1000px; margin: 22px auto 70px; padding: 0 20px;
  display: flex; flex-direction: column; gap: var(--gap);
}

/* status -------------------------------------------------------------- */

.status-line { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.status-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--text-dim); flex: none;
}
.status-dot.up { background: var(--good); box-shadow: 0 0 0 4px rgba(70,192,122,.15); }
.status-dot.busy { background: var(--warn); box-shadow: 0 0 0 4px rgba(224,168,60,.15); }
.status-dot.down { background: var(--danger); box-shadow: 0 0 0 4px rgba(224,85,85,.15); }
.status-headline { font-weight: 600; }

.status-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin: 0;
}
.status-grid dt { font-size: 12px; color: var(--text-dim);
                  text-transform: uppercase; letter-spacing: .05em; }
.status-grid dd { margin: 3px 0 0; font-size: 14px; word-break: break-all; }

/* model --------------------------------------------------------------- */

.model-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.model-filter { flex: 1 1 220px; }
.model-select { flex: 2 1 380px; font-family: ui-monospace, Menlo, monospace;
                font-size: 13px; }
.model-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tickbox { display: flex; align-items: center; gap: 7px; font-size: 13.5px;
           color: var(--text-dim); cursor: pointer; }

.countdown { margin-top: 16px; }
.countdown-bar {
  height: 8px; border-radius: 99px; background: var(--surface-high);
  overflow: hidden;
}
.countdown-bar > div {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), #7fb0ff);
  transition: width .25s linear;
}
#countdown-text { margin: 8px 0 0; font-size: 13.5px; color: var(--text-dim); }

.measure-box { margin-top: 16px; }
.measure-title { font-size: 12.5px; color: var(--text-dim); margin: 0 0 7px;
                 text-transform: uppercase; letter-spacing: .05em; }
.measure-list { list-style: none; margin: 0; padding: 0;
                display: flex; flex-wrap: wrap; gap: 7px; }
.measure-list li {
  background: var(--surface-high); border: 1px solid var(--border);
  border-radius: 99px; padding: 4px 10px; font-size: 12.5px;
  display: flex; align-items: center; gap: 7px;
  font-family: ui-monospace, Menlo, monospace;
}
.measure-list button {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0;
}
.measure-list button:hover { color: var(--danger); }
.measure-progress { margin-top: 12px; display: flex; align-items: center;
                    gap: 12px; flex-wrap: wrap; }
#measure-progress-text { margin: 0; font-size: 13.5px; color: var(--warn); }

/* the three boxes ------------------------------------------------------ */

.prompt-head { display: flex; align-items: center; justify-content: space-between;
               margin-bottom: 14px; }
.prompt-head h2 { margin: 0; }

.box { margin-bottom: 16px; }
.box-head { display: flex; align-items: center; justify-content: space-between;
            margin-bottom: 6px; }
.box-head h3 { margin: 0; }

.io-box {
  width: 100%; resize: vertical;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px; line-height: 1.65;
  background: var(--bg);
}
.io-box.thinking { color: #c3b6e8; }
.io-box.answer { color: #cfe6d5; }
.io-box[readonly] { cursor: default; }

.prompt-actions { display: flex; align-items: center; gap: 12px;
                  flex-wrap: wrap; }
.prompt-note { font-size: 13.5px; color: var(--text-dim); }

/* the auto-save toggle ------------------------------------------------- */

.toggle { display: flex; align-items: center; gap: 9px; cursor: pointer;
          user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 42px; height: 24px; border-radius: 99px;
  background: var(--surface-high); border: 1px solid var(--border);
  position: relative; transition: background .15s ease;
  flex: none;
}
.toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-dim); transition: transform .15s ease, background .15s ease;
}
.toggle input:checked + .toggle-track { background: var(--primary);
                                        border-color: var(--primary); }
.toggle input:checked + .toggle-track .toggle-knob {
  transform: translateX(18px); background: #fff;
}
.toggle-label { font-size: 13.5px; color: var(--text-dim); }

/* history -------------------------------------------------------------- */

.history-list { list-style: none; margin: 0; padding: 0;
                display: flex; flex-direction: column; gap: 6px; }
.history-item { display: flex; align-items: stretch; gap: 6px; }
.history-open {
  flex: 1; display: grid;
  grid-template-columns: 92px 1fr auto; align-items: center; gap: 12px;
  text-align: left; font: inherit; cursor: pointer;
  background: var(--surface-high); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; color: var(--text);
}
.history-open:hover { border-color: var(--primary); }
.history-when { color: var(--text-dim); font-size: 12.5px; }
.history-prompt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-model {
  color: var(--text-dim); font-size: 11.5px; max-width: 210px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, Menlo, monospace;
}
.history-delete {
  background: transparent; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text-dim); cursor: pointer; font-size: 16px; padding: 0 12px;
}
.history-delete:hover { background: rgba(224,85,85,.15);
                        border-color: var(--danger); color: #ff9d9d; }
.history-empty { color: var(--text-dim); font-size: 14px; padding: 6px 2px; }

/* account -------------------------------------------------------------- */

.password-form { max-width: 380px; }

/* the confirmation ----------------------------------------------------- */

.shade {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 20px;
}
.confirm-card { max-width: 380px; width: 100%; }
#confirm-text { margin: 0 0 18px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

@media (max-width: 620px) {
  .history-open { grid-template-columns: 1fr; gap: 3px; }
  .history-model { max-width: none; }
  .status-grid { grid-template-columns: 1fr 1fr; }
}
