:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #172033;
  --muted: #687386;
  --border: #dce2ea;
  --primary: #3157d5;
  --primary-dark: #2446b5;
  --danger: #c23744;
  --success-bg: #e9f8ef;
  --success-text: #17663a;
  --error-bg: #fff0f1;
  --error-text: #9a2935;
  --shadow: 0 12px 30px rgba(23, 32, 51, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100vh; margin: 0; display: flex; flex-direction: column; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { width: min(1080px, calc(100% - 32px)); margin-inline: auto; }
.narrow { width: min(480px, calc(100% - 32px)); }
.narrow-wide { width: min(760px, calc(100% - 32px)); }

.site-header { background: #111a2e; color: #fff; border-bottom: 1px solid #24304a; }
.header-inner { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: #fff; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.site-header nav { display: flex; align-items: center; gap: 18px; }
.site-header nav a, .link-button { color: #dbe3ff; }
.user-label { color: #aeb8ce; font-size: .9rem; }
.inline-form { display: inline; margin: 0; }
.link-button { border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }

main { flex: 1; padding-block: 48px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 30px; box-shadow: var(--shadow); }
.auth-panel h1, .panel h1 { margin: 4px 0 8px; font-size: clamp(1.7rem, 4vw, 2.25rem); letter-spacing: -0.035em; }
.eyebrow { margin: 0; color: var(--primary); font-size: .76rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); }

.field { margin-block: 20px; }
.field label { display: block; margin-bottom: 7px; font-weight: 700; }
.field small { display: block; color: var(--muted); margin-top: 6px; }
input, textarea { width: 100%; border: 1px solid #bfc8d6; border-radius: 8px; background: #fff; padding: 11px 12px; color: var(--text); font: inherit; }
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus { outline: 3px solid rgba(49, 87, 213, .18); border-color: var(--primary); }
.full-width { width: 100%; }
.auth-switch { text-align: center; margin: 22px 0 0; color: var(--muted); }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border: 1px solid transparent; border-radius: 8px; padding: 9px 15px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.button:hover { text-decoration: none; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.button-secondary:hover { background: #f3f5f8; }
.button-danger { background: #fff; color: var(--danger); border-color: #e7aeb4; }
.button-danger:hover { background: var(--error-bg); }
.form-actions, .detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.messages { margin-bottom: 18px; }
.alert { border-radius: 8px; padding: 12px 14px; margin: 14px 0; }
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid #bce6cc; }
.alert-error { background: var(--error-bg); color: var(--error-text); border: 1px solid #f0c2c7; }

.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 26px; }
.page-heading h1 { margin: 5px 0; font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.045em; }
.page-heading p { margin-bottom: 0; }
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.note-card { min-height: 210px; display: flex; flex-direction: column; justify-content: space-between; gap: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; box-shadow: 0 6px 18px rgba(23, 32, 51, .05); }
.note-card h2 { margin: 0 0 10px; font-size: 1.2rem; }
.note-card h2 a { color: var(--text); }
.note-preview { display: -webkit-box; overflow: hidden; margin: 0; color: var(--muted); line-height: 1.55; white-space: pre-line; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.note-meta { display: flex; justify-content: space-between; gap: 14px; align-items: center; font-size: .8rem; }
.note-meta time { color: var(--muted); }

.detail-heading { display: flex; justify-content: space-between; align-items: start; gap: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.detail-heading h1 { overflow-wrap: anywhere; }
.note-content { min-height: 180px; margin-block: 28px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.75; }
.back-link { display: inline-block; margin-top: 8px; }
.empty-state { text-align: center; padding-block: 60px; }
.empty-state h2 { margin-bottom: 8px; }
.error-code { margin: 0; color: var(--primary); font-weight: 900; font-size: 4rem; line-height: 1; }
.site-footer { padding: 24px 0; color: var(--muted); font-size: .85rem; text-align: center; }

@media (max-width: 700px) {
  .header-inner { padding-block: 14px; align-items: flex-start; }
  .site-header nav { justify-content: flex-end; flex-wrap: wrap; gap: 10px 14px; }
  .user-label { width: 100%; text-align: right; }
  main { padding-block: 30px; }
  .panel { padding: 22px; }
  .page-heading, .detail-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .detail-actions .button, .detail-actions form { flex: 1; }
  .detail-actions form .button { width: 100%; }
}
