:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a64;
  --border: #dedcd4;
  --accent: #2f5d50;
  --accent-text: #ffffff;
  --ok: #2f7a4f;
  --warn: #9a6a12;
  --err: #b3362e;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --surface: #211f1d;
    --text: #ecebe6;
    --muted: #9c9a92;
    --border: #3a3834;
    --accent: #7fb8a4;
    --accent-text: #10201b;
    --ok: #7cc79a;
    --warn: #e0b35c;
    --err: #f08a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 16px calc(env(safe-area-inset-bottom, 0px) + 32px);
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

h1 { font-size: 1.5rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 32px 0 8px; }

label { font-weight: 600; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 2px 0 10px; }
.error { color: var(--err); font-size: 0.9rem; margin: 8px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

input[type="password"], textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

textarea { resize: vertical; min-height: 7.5em; display: block; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  white-space: nowrap;
}
button:disabled { opacity: 0.55; cursor: progress; }
button.link { background: none; color: var(--muted); padding: 0; font-weight: 400; font-size: 0.9rem; text-decoration: underline; }

kbd { font: inherit; font-size: 0.75em; opacity: 0.7; margin-left: 4px; }
@media (hover: none) { kbd { display: none; } }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.check { font-weight: 400; color: var(--muted); display: flex; gap: 6px; align-items: center; font-size: 0.95rem; }

#history { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }

.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.item-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.item-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.item-meta { margin: 6px 0 0; color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.item-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding: 0; list-style: none; }
.item-files li {
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  color: var(--muted);
}

.status { font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.status-queued, .status-running, .status-sending { color: var(--muted); }
.status-done { color: var(--ok); }
.status-failed { color: var(--warn); }
.status-lost { color: var(--err); }
