:root {
  color-scheme: light dark;
  --bg: #f5f5f3;
  --surface: #ffffff;
  --border: #e0dfda;
  --text: #1c1c1a;
  --muted: #767671;
  --accent: #2b6cee;
  --accent-text: #ffffff;
  --danger: #c4392c;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --surface: #212226;
    --border: #34363b;
    --text: #edeceb;
    --muted: #9a9a96;
    --accent: #5a8dff;
    --accent-text: #0b0d10;
  }
}

* { box-sizing: border-box; }

/* An author rule's specificity can otherwise beat the UA [hidden] rule
   (e.g. ".screen { display: flex }" ties on specificity and wins on
   source order), so pin this down explicitly. Toggle visibility via the
   `hidden` property/attribute only — never via inline style. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 48px;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

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

#login-screen {
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.login-card label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-card input {
  font-size: 1.5rem;
  letter-spacing: 0.5em;
  text-align: center;
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.login-card button {
  margin-top: 4px;
}

/* ---- app shell ---- */

#app-screen {
  width: 100%;
  max-width: 640px;
}

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

.status {
  font-size: 0.75rem;
  color: var(--muted);
}
.status.live::before { content: "● "; color: #2fa84f; }
.status.down::before { content: "● "; color: var(--danger); }

#send-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px;
}

.field-label {
  font-size: 0.8rem;
  color: var(--muted);
}

textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: var(--sans);
  line-height: 1.4;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.send-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-text);
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: default; }

.link-btn {
  background: none;
  color: var(--muted);
  font-weight: 500;
  padding: 4px 6px;
  font-size: 0.8rem;
  text-decoration: underline;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0;
}

.history { width: 100%; }

.history-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.history-header h2 {
  font-size: 0.95rem;
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 12px 0;
}

#items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.item-time {
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  width: 3.4em;
}

.item-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.88rem;
  max-height: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
}

.copy-btn {
  padding: 6px 14px;
  font-size: 0.78rem;
}
.copy-btn.copied { background: #2fa84f; }

.delete-btn {
  background: none;
  color: var(--muted);
  padding: 6px 8px;
  font-size: 0.85rem;
}
.delete-btn:hover { color: var(--danger); }

@media (max-width: 480px) {
  .item { flex-wrap: wrap; }
  .item-time { order: 1; width: auto; }
  .item-actions { order: 2; margin-left: auto; }
  .item-text { order: 3; flex-basis: 100%; }
}
