:root {
  color-scheme: light dark;
  --bg: #f7f7f4;
  --text: #20201e;
  --muted: #6e6e68;
  --line: #d8d8d0;
  --panel: #fffffb;
  --panel-soft: #efefea;
  --accent: #34342f;
  --danger: #8a3a32;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #242421;
    --text: #ecebe4;
    --muted: #aaa89f;
    --line: #44443e;
    --panel: #2d2d29;
    --panel-soft: #383831;
    --accent: #f2f1e8;
    --danger: #d48a80;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell[data-auth-loading] {
  visibility: hidden;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 18px;
}

.auth-view[hidden] {
  display: none;
}

.auth-page {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 34px 36px;
  overflow: hidden;
}

.auth-page h1 {
  text-align: center;
}

.error-page {
  text-align: center;
}

.error-copy {
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.error-action {
  display: block;
  margin-top: 24px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  padding: 11px 13px;
  text-decoration: none;
}

.auth-creature {
  margin: 0 0 18px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 22px;
  line-height: 1.14;
  width: max-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
  white-space: pre;
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.google-button {
  margin-top: 22px;
  width: 100%;
}

.auth-page .google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  margin-top: 20px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
  font-weight: 500;
}

.auth-page .google-button:hover {
  border-color: var(--accent);
  background: var(--accent);
}

.google-mark {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: #4285f4;
  font-family: Arial, sans-serif;
  font-weight: 700;
  line-height: 1;
}

.google-profile-notice {
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.google-profile-notice[hidden] {
  display: none;
}

.google-profile-notice strong {
  display: block;
  color: var(--text);
  font-weight: 400;
  word-break: break-all;
}

.auth-divider {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.auth-divider[hidden] {
  display: none;
}

.auth-note {
  margin-top: 8px;
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  min-height: 54px;
  padding: 13px 15px;
  font: inherit;
}

.email-verify-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
}

.auth-form[data-mode="signup"] .email-verify-row,
.auth-form[data-mode="resetRequest"] .email-verify-row {
  grid-template-columns: 1fr 68px;
}

.email-verify-row input {
  min-width: 0;
}

.email-verify-button {
  min-width: 0;
  margin-top: 0;
}

.auth-form select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  min-height: 54px;
  padding: 13px 15px;
  font: inherit;
}

.field-hint {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field-hint[hidden] {
  display: none;
}

.field-hint.ok {
  color: var(--muted);
}

.field-hint.error {
  color: var(--danger);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.text-button:hover {
  color: var(--text);
  text-decoration: underline;
}

.forgot-button {
  justify-self: start;
  margin-top: -2px;
  font-size: 13px;
}

.birthday-fields {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
}

.birthday-fields[hidden] {
  display: none;
}

.age-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.age-confirm[hidden] {
  display: none;
}

.age-confirm input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.birthday-line {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.auth-page button {
  width: 100%;
  margin-top: 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  padding: 10px 13px;
  cursor: pointer;
}

.auth-page button:disabled {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  cursor: not-allowed;
}

.auth-actions button {
  min-height: 54px;
  margin-top: 0;
  padding: 10px 13px;
  font-weight: 500;
}

.auth-actions .ghost-button {
  background: transparent;
  color: var(--accent);
}

.auth-page .forgot-button {
  width: fit-content;
  min-height: auto;
  margin: -1px 0 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 13px;
}

.auth-page .forgot-button:hover {
  color: var(--text);
  text-decoration: underline;
}

.auth-page .email-verify-button {
  width: 68px;
  margin-top: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

.auth-page .email-verify-button:disabled {
  background: var(--panel-soft);
  color: var(--muted);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.shell {
  width: min(100%, 700px);
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.policy-page {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 38px 18px 56px;
  line-height: 1.75;
}

.policy-page h1 {
  margin-bottom: 24px;
}

.policy-page h2 {
  margin-top: 28px;
  font-size: 19px;
}

.policy-page p {
  margin: 10px 0 0;
}

.policy-back {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.topbar-right {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.account-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-box[hidden] {
  display: none;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", "Noto Serif KR", serif;
  font-weight: 500;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 20px;
}

nav {
  display: flex;
  gap: 4px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.nav-button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 8px 12px;
  cursor: pointer;
}

.nav-button:last-child {
  border-right: 0;
}

.nav-button.active {
  background: var(--accent);
  color: var(--bg);
}

.view {
  display: none;
  padding-top: 28px;
}

.view.active {
  display: block;
}

.progress-meta,
.todo-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.date-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: start;
  gap: 12px;
}

#todayTitle {
  white-space: nowrap;
  font-family: "Noto Serif KR", "Noto Serif CJK KR", "Nanum Myeongjo", Batang, serif;
  line-height: 1.35;
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.muted,
.save-state {
  color: var(--muted);
  font-size: 13px;
}

.clock {
  margin: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  white-space: nowrap;
}

.save-state.error {
  color: var(--danger);
}

.creature-panel {
  margin: 32px 0 26px;
  text-align: center;
}

.creature-panel pre,
.creature-panel h3,
.creature-panel .quote {
  cursor: pointer;
  user-select: none;
}

.choice-panel {
  padding-top: 4px;
}

.choice-panel .muted {
  margin: 14px 0 16px;
}

.species-choices {
  display: grid;
  gap: 10px;
}

.species-card {
  display: grid;
  justify-items: center;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 18px 14px 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.species-card:hover {
  border-color: var(--accent);
}

.species-card pre {
  min-height: 78px;
  margin: 0 0 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 24px;
  line-height: 1.25;
  white-space: pre;
}

.species-card strong,
.species-card span {
  display: block;
}

.species-card span {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.6;
}

.creature-face {
  margin: 0 0 14px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 31px;
  line-height: 1.25;
  white-space: pre;
  text-align: center;
}

.creature-face.small {
  font-size: 28px;
  margin-top: 16px;
}

.quote {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.quote::before,
.quote::after {
  content: "\"";
}

.moment-line {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--text);
  font-size: 14px;
}

.progress-panel {
  margin-bottom: 22px;
}

.progress-track {
  height: 8px;
  margin-top: 9px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 160ms ease;
}

.todo-panel,
.archive-card,
.detail-dialog article {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.todo-item {
  display: grid;
  grid-template-columns: 34px 1fr 168px auto;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
}

.todo-item.target-warning {
  background: #fbf7eb;
  background: color-mix(in srgb, var(--panel) 88%, #8a6f32);
}

.todo-item.target-soon {
  background: #fbf1e9;
  background: color-mix(in srgb, var(--panel) 84%, #8a5132);
}

.todo-item.target-critical,
.todo-item.target-over {
  background: #faeeec;
  background: color-mix(in srgb, var(--panel) 78%, var(--danger));
  box-shadow: inset 3px 0 0 var(--danger);
}

.todo-item.done .todo-text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.todo-item.age-fresh .todo-text {
  color: var(--text);
}

.todo-item.age-waiting .todo-text {
  color: #5f5f58;
}

.todo-item.age-stale .todo-text {
  color: #4b4942;
}

.todo-item.age-late .todo-text {
  color: #2f2e29;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .todo-item.age-waiting .todo-text {
    color: #c4c1b7;
  }

  .todo-item.age-stale .todo-text {
    color: #d4cfc1;
  }

  .todo-item.age-late .todo-text {
    color: #ece6d6;
  }
}

.todo-check {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
}

.todo-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.todo-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.todo-slot {
  min-width: 0;
}

.priority-badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  padding: 2px 5px;
}

.todo-item.target-warning .priority-badge,
.todo-item.target-soon .priority-badge {
  border-color: #8a6f32;
  color: #6f5621;
}

.todo-item.target-critical .priority-badge,
.todo-item.target-over .priority-badge {
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 700;
}

.todo-meta {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.deadline-button,
.deadline-empty {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--accent);
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.deadline-button {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 600;
}

.deadline-badge {
  border: 1px solid currentColor;
  padding: 2px 7px;
  font-size: 11px;
  line-height: 1.4;
}

.completion-badge {
  display: inline-block;
  width: fit-content;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 2px 7px;
  font-size: 11px;
  line-height: 1.4;
}

.completion-badge.early {
  border-color: #5f6f46;
  color: #4f6338;
}

.completion-badge.late {
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 700;
}

.completion-badge.ontime {
  border-color: var(--accent);
  color: var(--accent);
}

.todo-item.target-warning .deadline-button {
  color: #6f5621;
}

.todo-item.target-soon .deadline-button {
  color: #7a4828;
  font-weight: 700;
}

.todo-item.target-critical .deadline-button,
.todo-item.target-over .deadline-button {
  color: var(--danger);
  font-weight: 800;
}

.deadline-empty {
  color: var(--muted);
  font-size: 12px;
}

.deadline-button:hover,
.deadline-empty:hover {
  border-bottom-color: var(--line);
}

.todo-target-select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  padding: 5px 5px;
}

.todo-target-group,
.target-time-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  min-width: 0;
}

.todo-time {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  white-space: nowrap;
}

.done-time {
  color: var(--accent);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
}

.target-bar {
  display: block;
  width: 100%;
  height: 5px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.target-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--muted);
}

.todo-item.target-soon .target-fill {
  background: #8a6f32;
}

.todo-item.target-critical .target-fill {
  background: #a94d3f;
}

.todo-item.target-over .target-fill {
  background: var(--danger);
}

.todo-edit-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  padding: 7px 8px;
}

.item-buttons {
  display: flex;
  gap: 2px;
}

.icon-button {
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover,
.archive-card:hover {
  border-color: var(--accent);
}

.delete-button {
  color: var(--danger);
}

.add-form {
  display: grid;
  grid-template-columns: 1fr 150px auto;
  gap: 8px;
  padding: 10px;
}

.add-form input {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  padding: 10px 11px;
}

.target-time-input {
  color: var(--muted);
}

.add-form button,
.close-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  padding: 10px 13px;
  cursor: pointer;
}

.todo-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  padding: 0 10px 10px;
}

.inline-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.inline-confirm[hidden] {
  display: none;
}

.top-confirm {
  justify-content: flex-start;
  margin-top: 10px;
}

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  cursor: pointer;
}

.ghost-button:hover {
  border-color: var(--danger);
  color: var(--danger);
}

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

.archive-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.archive-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.archive-tabs {
  display: flex;
  border: 1px solid var(--line);
  background: var(--panel);
}

.archive-filter {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 7px 10px;
  cursor: pointer;
}

.archive-filter:last-child {
  border-right: 0;
}

.archive-filter.active {
  background: var(--accent);
  color: var(--bg);
}

.archive-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  text-align: left;
}

.archive-card-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.archive-delete-button {
  flex: 0 0 auto;
  color: var(--danger);
}

.archive-card pre {
  margin: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 22px;
  text-align: center;
}

.archive-card p {
  margin: 6px 0 0;
}

.my-list {
  display: grid;
  gap: 10px;
  margin: 20px 0;
  border-top: 1px solid var(--line);
}

.my-list div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.my-list dt {
  color: var(--muted);
}

.my-list dd {
  margin: 0;
}

.my-form {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.my-form label {
  display: grid;
  gap: 7px;
}

.my-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  padding: 10px 11px;
  font: inherit;
}

.my-form button {
  width: fit-content;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  padding: 9px 12px;
  cursor: pointer;
}

.my-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.delete-confirm {
  margin-top: 14px;
}

.empty {
  padding: 32px 0;
  color: var(--muted);
}

.detail-dialog {
  width: min(92vw, 560px);
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.36);
}

.detail-dialog article {
  position: relative;
  padding: 24px;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  padding: 0;
}

.detail-todos {
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.detail-todos li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.detail-actions {
  margin-top: 22px;
  display: grid;
  gap: 10px;
}

@media (max-width: 520px) {
  .shell {
    padding: 16px 12px 32px;
  }

  .topbar {
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
  }

  .topbar-right {
    gap: 7px;
  }

  .account-box {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  h1 {
    font-size: 24px;
    line-height: 1.15;
  }

  .date-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    row-gap: 6px;
  }

  .status-actions,
  .todo-footer,
  .inline-confirm {
    flex-wrap: wrap;
  }

  .status-actions {
    grid-column: 1 / -1;
    gap: 6px;
  }

  .clock {
    justify-self: end;
    margin-top: 5px;
  }

  #todayTitle {
    font-size: 20px;
  }

  nav {
    flex: 0 0 auto;
  }

  .nav-button {
    padding: 8px 11px;
  }

  .view {
    padding-top: 20px;
  }

  .creature-panel {
    margin: 22px 0 18px;
  }

  .creature-face {
    font-size: 27px;
    margin-bottom: 10px;
  }

  .creature-panel h3 {
    font-size: 18px;
  }

  .quote {
    margin-top: 8px;
    font-size: 14px;
  }

  .progress-panel {
    margin-bottom: 14px;
  }

  .archive-card {
    grid-template-columns: 1fr;
  }

  .archive-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .archive-tabs,
  .archive-filter {
    width: 100%;
  }

  .add-form {
    grid-template-columns: 1fr;
  }

  .target-time-group {
    grid-template-columns: 1fr 1fr;
  }

  .todo-item {
    grid-template-columns: 34px 1fr auto;
  }

  .todo-meta {
    grid-column: 2;
    max-width: 180px;
  }

  .item-buttons {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

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

  .target-time-input {
    width: 100%;
  }

  .auth-view {
    align-items: start;
    padding: 96px 16px 24px;
  }

  .auth-page {
    width: min(100%, 625px);
    padding: 32px 28px;
  }

  .auth-creature {
    font-size: 20px;
    margin-bottom: 14px;
  }

  .auth-page h1 {
    font-size: 32px;
  }

  .auth-form {
    gap: 12px;
  }
}

@media (max-width: 380px) {
  .date-row {
    grid-template-columns: 1fr;
  }

  .clock {
    justify-self: start;
    margin-top: 0;
  }

  .auth-view {
    padding: 82px 14px 24px;
  }

  .auth-page {
    padding: 30px 22px;
  }
}
