:root {
  --paper: #fbf4de;
  --paper-deep: #efe0bd;
  --ink: #14243a;
  --muted-ink: #6f7378;
  --line: rgba(99, 146, 176, 0.28);
  --margin: rgba(188, 88, 78, 0.28);
  --tab: #e2d0a7;
  --green: #375a43;
  --red: #a7463e;
  --shadow: 0 22px 60px rgba(59, 43, 20, 0.2);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 18%, rgba(255, 255, 255, 0.5), transparent 24rem),
    linear-gradient(125deg, #d4c6a6, #95856b);
  color: var(--ink);
  font-family: "Neucha", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid rgba(67, 49, 28, 0.26);
  border-radius: 7px;
  background: rgba(255, 251, 239, 0.72);
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(91, 62, 33, 0.16);
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
  box-shadow: none;
}

input,
textarea,
select {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(18, 44, 72, 0.35);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 28px;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.auth-card,
.notebook-page {
  position: relative;
  width: min(980px, 100%);
  background:
    linear-gradient(90deg, transparent 0 52px, var(--margin) 53px 55px, transparent 56px),
    repeating-linear-gradient(0deg, transparent 0 30px, var(--line) 31px 32px),
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.44), transparent 16rem),
    var(--paper);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  max-width: 430px;
  padding: 34px 30px 30px 76px;
}

.brand {
  margin: 0 0 4px;
  font-family: "Bad Script", cursive;
  font-size: 38px;
}

.hint {
  margin: 0 0 22px;
  color: #5e5d55;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.auth-switch button.active,
.tabs button.active,
.subtabs button.active {
  background: rgba(55, 90, 67, 0.14);
  border-color: rgba(55, 90, 67, 0.45);
}

.error {
  min-height: 22px;
  color: var(--red);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
}

.sidebar {
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(71, 54, 36, 0.34);
  backdrop-filter: blur(8px);
}

.userbox {
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 251, 239, 0.7);
}

.userbox strong {
  display: block;
  font-size: 21px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tabs button {
  text-align: left;
  padding: 8px 10px;
  background: var(--tab);
}

.logout {
  margin-top: auto;
}

.notebook-page {
  min-height: calc(100vh - 32px);
  padding: 28px 28px 40px 78px;
}

.page-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-header h1 {
  margin: 0;
  font-family: "Bad Script", cursive;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.08;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.subtabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 18px;
}

.subtabs button {
  padding: 6px 12px;
}

.grid {
  display: grid;
  gap: 16px;
}

.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  padding: 14px 0 4px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 27px;
}

.paper-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.paper-form .wide {
  grid-column: span 2;
}

.paper-form button {
  padding: 6px 12px;
}

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

.row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  min-height: 32px;
  padding: 3px 0;
}

.row:nth-child(3n + 1) {
  transform: rotate(-0.15deg);
}

.row:nth-child(3n + 2) {
  transform: translateX(2px) rotate(0.12deg);
}

.check {
  width: 23px;
  height: 23px;
  min-height: 23px;
  margin-top: 2px;
  border-radius: 50%;
  background: transparent;
  position: relative;
}

.check.done::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: rgba(20, 36, 58, 0.72);
}

.hand {
  font-family: "Bad Script", cursive;
  font-size: 22px;
  line-height: 30px;
}

.meta {
  color: var(--muted-ink);
  font-size: 15px;
}

.done-text {
  color: #8a8d8f;
  text-decoration: line-through;
}

.missed {
  color: var(--red);
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.actions button,
.icon-button {
  width: 34px;
  min-height: 32px;
  padding: 0;
}

.rating {
  display: inline-flex;
  gap: 2px;
}

.rating button {
  width: 30px;
  min-height: 30px;
  border: 0;
  box-shadow: none;
  background: transparent;
  color: #9a7a2c;
}

.empty {
  padding: 16px 0;
  color: #67645c;
}

.month-review,
.settings {
  display: grid;
  gap: 14px;
}

.search-results {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed rgba(20, 36, 58, 0.28);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(55, 90, 67, 0.12);
  color: var(--green);
  font-size: 15px;
}

.save-state {
  min-height: 20px;
  color: #5e5d55;
  text-align: right;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
  }

  .sidebar {
    position: fixed;
    z-index: 5;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: auto;
    border-radius: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }

  .userbox,
  .logout {
    display: none;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .tabs button {
    min-height: 46px;
    padding: 4px;
    text-align: center;
    font-size: 14px;
  }

  .notebook-page {
    min-height: 100vh;
    border-radius: 0;
    padding: 22px 14px 112px 56px;
  }

  .page-header {
    display: block;
  }

  .toolbar,
  .two,
  .paper-form {
    grid-template-columns: 1fr;
  }

  .paper-form .wide {
    grid-column: auto;
  }

  .row {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}
