:root {
  color-scheme: light dark;
  --bg: #12140f;
  --card: #1b1f17;
  --card-raised: #22281d;
  --text: #f1f0e9;
  --muted: #a8ad9f;
  --accent: #d6b86a;
  --accent-ink: #1e190d;
  --line: #343b2c;
  --danger: #f0a59b;
  --success: #9cc89a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(109, 123, 76, .2), transparent 35rem),
    var(--bg);
  color: var(--text);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-card,
.editor-card {
  width: min(100%, 70rem);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  border-radius: 1.25rem;
  box-shadow: 0 2rem 5rem rgba(0, 0, 0, .28);
}

.login-card {
  width: min(100%, 27rem);
  padding: clamp(1.5rem, 6vw, 3rem);
}

.mark {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: 2rem;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
}

.eyebrow {
  margin: 0 0 .4rem;
  color: var(--accent);
  font-size: .76rem;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: clamp(1.7rem, 5vw, 2.55rem); line-height: 1.08; }
.muted, .path { color: var(--muted); }

form { margin-top: 2rem; }
label { display: block; margin-bottom: .5rem; font-weight: 650; }
input {
  width: 100%;
  min-height: 3.2rem;
  padding: .8rem 1rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  background: var(--bg);
  color: var(--text);
}

input:focus, textarea:focus, button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent);
  outline-offset: 2px;
}

button {
  min-height: 2.75rem;
  padding: .65rem 1rem;
  border: 0;
  border-radius: .65rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 780;
}

form button { width: 100%; margin-top: 1rem; }
.ghost { border: 1px solid var(--line); background: transparent; color: var(--text); }
.error { min-height: 1.35rem; color: var(--danger); }

.editor-card { overflow: hidden; }
.editor-card header,
.editor-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem clamp(1rem, 4vw, 2rem);
}

.editor-card header { border-bottom: 1px solid var(--line); }
.editor-card footer { border-top: 1px solid var(--line); }
.path { margin: .45rem 0 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }

textarea {
  display: block;
  width: 100%;
  min-height: min(64vh, 48rem);
  resize: vertical;
  padding: clamp(1rem, 4vw, 2rem);
  border: 0;
  background: var(--card-raised);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1rem;
  line-height: 1.65;
  tab-size: 2;
}

.status { font-size: .88rem; }
.status[data-kind="saved"] { color: var(--success); }
.status[data-kind="dirty"] { color: var(--accent); }
.status[data-kind="error"] { color: var(--danger); }
.count { margin-left: .7rem; color: var(--muted); font-size: .78rem; }

.conflict {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid #714d47;
  background: #392723;
  color: #ffd9d2;
}
.conflict[hidden] { display: none; }
.conflict-actions { display: flex; gap: .5rem; margin-left: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 640px) {
  .shell { padding: 0; place-items: stretch; }
  .login-card { align-self: center; justify-self: center; margin: 1rem; }
  .editor-card { min-height: 100vh; border: 0; border-radius: 0; }
  .editor-card header { align-items: flex-start; }
  textarea { min-height: calc(100vh - 15rem); }
  .editor-card footer { position: sticky; bottom: 0; background: var(--card); }
  .conflict { align-items: flex-start; flex-direction: column; }
  .conflict-actions { width: 100%; margin-left: 0; }
  .conflict-actions button { flex: 1; }
  .count { display: block; margin: .2rem 0 0; }
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f0e8;
    --card: #fbfaf5;
    --card-raised: #fffefa;
    --text: #25271f;
    --muted: #676d61;
    --accent: #79611f;
    --accent-ink: #fffdf4;
    --line: #d7d7cc;
    --danger: #9f3529;
    --success: #39723b;
  }
  .conflict { background: #fff0ec; color: #752b24; }
}
