:root {
  --paper: #f1e9db;
  --sheet: #fcf7ec;
  --sheet-soft: #f7efe2;
  --ink: #26221c;
  --ink-soft: #4a4234;
  --muted: #a1957f;
  --muted-dark: #6b6253;
  --rule: #d9cdb8;
  --rule-soft: #e6dcc8;
  --line: #ece1cd;
  --accent: #b9603a;
  --accent-hover: #a4512f;
  --good: #4f6f4a;
  --good-soft: #6f8a64;
  --bad: #b5503f;
  --warning: #9a6a20;
  --shadow: 0 24px 54px rgba(91, 70, 43, 0.08);
  --sans: "Hanken Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

h1,
h2,
p {
  margin-top: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 3px;
  background: var(--accent);
  color: var(--sheet-soft);
  padding: 0.78rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
}

button:disabled {
  cursor: wait;
  opacity: 0.78;
}

.topbar {
  border-bottom: 1px solid rgba(38, 34, 24, 0.06);
  background: var(--paper);
}

.topbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 22px 32px 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: grid;
  gap: 6px;
}

.brand-title {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.875rem;
  font-weight: 600;
  line-height: 1;
}

.brand-kicker {
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-bottom: 4px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.main-nav a,
.ghost-button {
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

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

.main-nav a:hover,
.ghost-button:hover {
  background: transparent;
  color: var(--accent);
}

.masthead-rule {
  height: 2px;
  background: var(--accent);
}

.shell {
  max-width: 1140px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: grid;
  gap: 0.5rem;
}

.message {
  border: 1px solid #c9d9c0;
  background: #eef6ea;
  color: #35552e;
  padding: 0.7rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.message.info {
  border-color: #dcc995;
  background: #fbf2dd;
  color: #684b16;
}

.message.error {
  border-color: #d9aaa1;
  background: #fff0ed;
  color: #843226;
}

.diary-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  align-items: start;
  gap: 56px;
}

.entry-list {
  position: sticky;
  top: 32px;
  min-width: 0;
}

.selected-day {
  margin-bottom: 22px;
}

.selected-day h1 {
  margin-bottom: 8px;
  font-family: var(--serif);
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.02;
}

.selected-day span {
  color: #8c8474;
  font-size: 0.875rem;
}

.sidebar-action {
  margin-bottom: 38px;
}

.sidebar-action button {
  width: 100%;
}

.pending-label,
.sidebar-action button[data-state="pending"] [data-ready-label] {
  display: none;
}

.sidebar-action button[data-state="pending"] [data-pending-label] {
  display: inline;
}

.correction-pending {
  margin: 0.55rem 0 0;
  color: var(--warning);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
}

.short-label {
  display: none;
}

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

.today-link {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.entry-list nav {
  display: block;
}

.entry-link {
  display: block;
  padding: 13px 0;
  border-bottom: 1px solid #e3d9c7;
  color: inherit;
}

.entry-link:hover {
  color: inherit;
}

.entry-link:hover .entry-date {
  color: var(--accent);
}

.entry-link.active .entry-date {
  color: var(--accent);
}

.entry-link-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.entry-date {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 600;
  transition: color 0.12s ease;
}

.entry-status {
  color: var(--good-soft);
  font-size: 0.6875rem;
  font-weight: 600;
}

.entry-status.today-status {
  color: var(--muted);
  font-weight: 400;
}

.entry-link small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #9a907e;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-link small.empty {
  color: #b7ac98;
  font-style: italic;
}

.muted,
.empty {
  color: var(--muted-dark);
}

.editor-panel {
  min-width: 0;
}

.editor-form {
  background: var(--sheet);
  border: 1px solid var(--rule-soft);
  box-shadow: var(--shadow);
  padding: 44px 56px 0;
}

.editor-greeting {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 26px;
}

.editor-greeting span:first-child {
  color: var(--muted);
  font-family: var(--serif);
  font-size: 1.0625rem;
  font-style: italic;
}

.editor-greeting span:last-child,
.editor-actions span {
  color: var(--muted);
  font-size: 0.78rem;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--sheet);
  color: var(--ink);
  padding: 0.8rem;
}

textarea {
  min-height: min(62dvh, 680px);
  resize: vertical;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-image: linear-gradient(to bottom, transparent 37px, var(--line) 37px, var(--line) 38px);
  background-size: 100% 38px;
  padding: 0 0 38px;
  color: #2c281f;
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 38px;
}

textarea::placeholder {
  color: #b7ac98;
  opacity: 1;
}

textarea:focus,
input:focus {
  outline: 2px solid rgba(185, 96, 58, 0.28);
  outline-offset: 3px;
}

.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 8px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.editor-actions span[data-state="pending"],
.editor-actions span[data-state="saving"] {
  color: var(--warning);
}

.editor-actions span[data-state="saved"] {
  color: var(--good);
}

.editor-actions span[data-state="error"] {
  color: var(--bad);
  font-weight: 700;
}

.editor-actions button,
.secondary-button {
  width: auto;
  min-height: 38px;
  border: 1px solid #cdc1aa;
  background: transparent;
  color: var(--ink-soft);
  padding: 9px 18px;
  font-size: 0.8125rem;
  font-weight: 700;
}

.editor-actions button:hover,
.secondary-button:hover {
  border-color: var(--accent);
  background: transparent;
  color: var(--accent);
}

.field-errors {
  color: var(--bad);
  font-weight: 700;
}

.eyebrow {
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.correction-panel {
  margin-top: 48px;
}

.correction-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 4px;
}

.correction-title-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 14px;
}

.correction-panel h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: 0;
}

.status-pill {
  color: var(--good-soft);
  font-size: 0.75rem;
  font-weight: 600;
}

.status-pill.error {
  color: var(--bad);
}

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

.correction-summary {
  max-width: 60ch;
  margin: 0 0 28px;
  color: var(--muted-dark);
  font-family: var(--serif);
  font-size: 1.0625rem;
  font-style: italic;
  line-height: 1.55;
}

.corrected-text {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.corrected-text-panel {
  padding: 22px 0;
}

.corrected-text pre {
  white-space: pre-wrap;
  margin: 0;
  color: #2f3a2c;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 2;
}

.issue-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.issue-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 4px;
  padding: 26px 0;
  border-bottom: 1px solid #e3d9c7;
}

.issue-number {
  color: #c4a886;
  font-family: var(--serif);
  font-size: 1.375rem;
  line-height: 1;
}

.issue-card-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 8px;
  font-family: var(--serif);
  font-size: 1.125rem;
}

.issue-original {
  color: var(--bad);
  text-decoration: line-through;
  text-decoration-color: #cf9b8c;
}

.issue-correction {
  color: var(--good);
  font-weight: 500;
}

.issue-category {
  align-self: center;
  color: #b09a76;
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.issue-card p {
  max-width: 64ch;
  margin: 0;
  color: #5e564a;
  font-size: 0.9375rem;
  line-height: 1.65;
}

.example {
  margin-top: 0.55rem;
  color: var(--muted-dark);
  font-style: italic;
}

.practice-tip {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 2px solid var(--accent);
}

.practice-tip .eyebrow {
  color: var(--accent);
}

.practice-tip p:last-child {
  max-width: 62ch;
  margin: 0;
  color: #3a352b;
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
}

.auth-panel {
  max-width: 460px;
  margin: 1rem auto;
  background: var(--sheet);
  border: 1px solid var(--rule-soft);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.auth-panel h1 {
  margin-bottom: 0.35rem;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
}

.login-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.25rem;
}

.login-form p {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.login-form label {
  color: var(--ink-soft);
  font-weight: 700;
}

.login-form button {
  width: 100%;
}

@media (max-width: 780px) {
  .topbar-inner {
    padding: 18px 20px 15px;
  }

  .brand-title {
    font-size: 1.65rem;
  }

  .topbar-actions,
  .main-nav {
    gap: 16px;
  }

  .shell {
    padding: 28px 20px 56px;
  }

  .diary-layout {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .entry-list {
    position: static;
  }

  .selected-day {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 16px;
  }

  .selected-day h1 {
    margin-bottom: 0;
    font-size: 2rem;
  }

  .sidebar-action {
    margin-bottom: 24px;
  }

  .entry-list nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 18px;
  }

  .editor-form {
    padding: 32px 28px 0;
  }
}

@media (max-width: 560px) {
  .topbar-inner {
    align-items: flex-start;
    padding: 16px 16px 13px;
  }

  .brand-kicker,
  .main-nav {
    display: none;
  }

  .shell {
    padding: 22px 16px 44px;
  }

  .entry-list nav {
    grid-template-columns: 1fr;
  }

  .short-label {
    display: inline;
  }

  .wide-label,
  .sidebar-action button[data-state="pending"] .wide-label {
    display: none;
  }

  .sidebar-action button[data-state="pending"] .short-label[data-pending-label] {
    display: inline;
  }

  .sidebar-action button[data-state="pending"] .short-label[data-ready-label] {
    display: none;
  }

  .editor-form {
    padding: 26px 18px 0;
  }

  .editor-greeting,
  .editor-actions,
  .correction-head {
    align-items: flex-start;
    flex-direction: column;
  }

  textarea {
    min-height: 52dvh;
    font-size: 1.125rem;
  }

  .editor-actions button {
    width: 100%;
  }

  .issue-card {
    grid-template-columns: 30px minmax(0, 1fr);
  }
}
