:root {
  --ink: #243129;
  --muted: #748078;
  --page: #f3f6f2;
  --panel: #ffffff;
  --line: rgba(49, 72, 57, 0.12);
  --line-strong: rgba(49, 72, 57, 0.2);
  --green: #2f9c5c;
  --coral: #d76056;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgba(79, 158, 107, 0.13), transparent 34rem),
    radial-gradient(circle at 88% 12%, rgba(215, 96, 86, 0.07), transparent 30rem),
    var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid #4ba871;
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 278px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
}

.brand > span:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.brand-mark,
.empty-mark {
  position: relative;
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  overflow: hidden;
  border: 1px solid rgba(47, 156, 92, 0.22);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(47, 156, 92, 0.12), transparent 60%), #f7fbf7;
}

.brand-mark i,
.empty-mark i {
  position: relative;
  display: block;
  width: 4px;
  border-radius: 3px;
  background: var(--green);
}

.brand-mark i::before,
.empty-mark i::before {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 50%;
  width: 1px;
  content: "";
  background: currentColor;
  transform: translateX(-50%);
}

.brand-mark i:nth-child(1),
.empty-mark i:nth-child(1) {
  height: 9px;
  color: var(--coral);
  background: var(--coral);
  transform: translateY(4px);
}

.brand-mark i:nth-child(2),
.empty-mark i:nth-child(2) {
  height: 16px;
  transform: translateY(-1px);
}

.brand-mark i:nth-child(3),
.empty-mark i:nth-child(3) {
  height: 11px;
  transform: translateY(-5px);
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  font-size: 11px;
}

.local-badge > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(47, 156, 92, 0.1);
}

.chart-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(47, 156, 92, 0.018), transparent 26%), var(--panel);
  box-shadow: 0 24px 70px rgba(36, 55, 43, 0.1);
}

.error-banner {
  display: flex;
  gap: 10px;
  margin: 18px 18px 0;
  padding: 12px 14px;
  border: 1px solid rgba(215, 96, 86, 0.25);
  border-radius: 12px;
  color: #a63f38;
  background: #fff2f0;
  font-size: 12px;
}

.error-banner span {
  color: #a65b55;
}

.day-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  transition: background 220ms ease;
}

.day-toolbar[data-score-state="positive"] {
  background: linear-gradient(
    180deg,
    rgba(47, 156, 92, 0.22) 0%,
    rgba(47, 156, 92, 0.08) 54%,
    #ffffff 100%
  );
}

.day-toolbar[data-score-state="negative"] {
  background: linear-gradient(
    180deg,
    rgba(215, 96, 86, 0.22) 0%,
    rgba(215, 96, 86, 0.08) 54%,
    #ffffff 100%
  );
}

.date-navigation {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-button,
.today-button,
.undo-button,
.return-today-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(36, 49, 41, 0.025);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.nav-button:hover:not(:disabled),
.today-button:hover:not(:disabled),
.undo-button:hover:not(:disabled),
.return-today-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: rgba(36, 49, 41, 0.06);
}

.nav-button:active:not(:disabled),
.today-button:active:not(:disabled),
.undo-button:active:not(:disabled),
.return-today-button:active:not(:disabled) {
  transform: translateY(1px);
}

.nav-button {
  width: 36px;
  height: 36px;
  color: #55635a;
  font-size: 17px;
}

.today-button {
  min-height: 36px;
  padding: 0 12px;
  color: #647168;
  font-size: 12px;
}

.date-copy {
  display: grid;
  min-width: 148px;
  gap: 2px;
  padding: 0 4px;
}

.date-copy span {
  font-size: 14px;
  font-weight: 650;
}

.date-copy strong {
  color: var(--muted);
  font-size: 11px;
  font-weight: 450;
}

.score-group {
  display: flex;
}

.score-card {
  display: grid;
  min-width: 92px;
  gap: 2px;
  padding: 0 18px;
  border-left: 1px solid var(--line);
  text-align: right;
}

.score-card span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.score-card strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 24px;
  font-weight: 560;
  letter-spacing: -0.05em;
}

.score-card strong.positive {
  color: var(--green);
}

.score-card strong.negative {
  color: var(--coral);
}

.chart-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px 8px;
}

.eyebrow {
  color: #718078;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.17em;
}

.chart-header h1 {
  margin: 8px 0 0;
  color: #243129;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 520;
  letter-spacing: -0.045em;
}

.legend {
  display: flex;
  gap: 18px;
  padding-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend b {
  font-weight: 500;
}

.legend i {
  width: 7px;
  height: 7px;
  border-radius: 2px;
}

.legend .up i {
  background: var(--green);
}

.legend .down i {
  background: var(--coral);
}

.chart-stage {
  position: relative;
  min-height: 410px;
  margin: 0 14px;
}

.chart-canvas {
  position: absolute;
  inset: 0;
  min-height: 410px;
}

.empty-state,
.loading-state {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: flex;
  width: min(340px, calc(100% - 40px));
  align-items: center;
  flex-direction: column;
  text-align: center;
  transform: translate(-50%, -46%);
}

.empty-state {
  pointer-events: none;
}

.empty-mark {
  width: 54px;
  height: 54px;
  margin-bottom: 18px;
  border-radius: 16px;
  opacity: 0.86;
}

.empty-state strong {
  color: #2d3a32;
  font-size: 15px;
  font-weight: 600;
}

.empty-state p {
  max-width: 310px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.loading-state {
  color: var(--muted);
  font-size: 12px;
}

.chart-footnote {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 28px 20px;
  color: #859088;
  font-size: 10px;
}

.chart-footnote span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.zero-line {
  display: inline-block;
  width: 20px;
  border-top: 1px dashed #95a198;
}

.entry-dock {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 12px 20px 18px;
  background: linear-gradient(180deg, transparent 0, rgba(243, 246, 242, 0.95) 16px, #f3f6f2 56px);
}

.entry-dock-inner {
  width: min(1140px, 100%);
  margin: 0 auto;
  padding: 15px 18px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(47, 156, 92, 0.025), transparent), rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 50px rgba(36, 55, 43, 0.14);
  backdrop-filter: blur(22px);
}

.dock-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.dock-heading > div {
  display: grid;
  gap: 2px;
}

.dock-heading strong {
  color: #344139;
  font-size: 13px;
  font-weight: 550;
}

.undo-button {
  min-height: 34px;
  padding: 0 11px;
  color: var(--muted);
  font-size: 11px;
}

.entry-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.entry-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 9px;
}

.entry-direction {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.entry-row.up .entry-direction {
  color: var(--green);
}

.entry-row.down .entry-direction {
  color: var(--coral);
}

.direction-arrow {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  font-size: 15px;
}

.up .direction-arrow {
  background: rgba(47, 156, 92, 0.09);
}

.down .direction-arrow {
  background: rgba(215, 96, 86, 0.09);
}

.intensity-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  gap: 6px;
}

.intensity-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 610;
  transition: transform 140ms ease, border-color 140ms ease, filter 140ms ease;
}

.entry-row.up .intensity-button {
  border-color: rgba(47, 156, 92, 0.17);
  color: #247c49;
  background: linear-gradient(180deg, rgba(47, 156, 92, 0.11), rgba(47, 156, 92, 0.055));
}

.entry-row.down .intensity-button {
  border-color: rgba(215, 96, 86, 0.17);
  color: #b44840;
  background: linear-gradient(180deg, rgba(215, 96, 86, 0.11), rgba(215, 96, 86, 0.05));
}

.intensity-button:hover:not(:disabled) {
  filter: saturate(1.12) brightness(0.98);
  transform: translateY(-1px);
}

.intensity-button:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.intensity-button span {
  margin-right: 1px;
  opacity: 0.62;
  font-size: 11px;
}

.dock-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid rgba(49, 72, 57, 0.08);
  color: #8a958e;
  font-size: 9px;
}

.dock-meta a {
  color: #66736b;
}

.save-notice {
  color: #6f7c73;
}

.history-message {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  min-height: 86px;
}

.history-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--muted);
  background: rgba(36, 49, 41, 0.025);
  font-size: 21px;
}

.history-message > div {
  display: grid;
  gap: 3px;
}

.history-message strong {
  color: #344139;
  font-size: 14px;
}

.history-message p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.return-today-button {
  min-height: 40px;
  padding: 0 15px;
  border-color: rgba(47, 156, 92, 0.22);
  color: #287f4b;
  background: rgba(47, 156, 92, 0.07);
  font-size: 12px;
}

@media (max-width: 780px) {
  .app-shell {
    width: min(100% - 24px, 1180px);
    padding-top: 16px;
    padding-bottom: 376px;
  }

  .site-header {
    margin-bottom: 14px;
  }

  .brand small {
    display: none;
  }

  .local-badge {
    padding: 8px;
    font-size: 0;
  }

  .day-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
  }

  .date-navigation {
    width: 100%;
  }

  .date-copy {
    flex: 1;
    min-width: 0;
  }

  .score-group {
    margin: 0 -16px -16px;
    border-top: 1px solid var(--line);
  }

  .score-card {
    flex: 1;
    padding: 12px 16px;
    border-left: 0;
    text-align: left;
  }

  .score-card + .score-card {
    border-left: 1px solid var(--line);
  }

  .chart-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 22px 20px 4px;
  }

  .chart-header h1 {
    font-size: 23px;
  }

  .chart-stage,
  .chart-canvas {
    min-height: 340px;
  }

  .chart-footnote {
    padding: 8px 20px 18px;
  }

  .chart-footnote span:last-child {
    display: none;
  }

  .entry-dock {
    padding: 10px 12px 12px;
  }

  .entry-dock-inner {
    padding: 13px 12px 9px;
    border-radius: 18px;
  }

  .entry-controls {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .entry-row {
    grid-template-columns: 68px 1fr;
  }

  .intensity-grid {
    gap: 5px;
  }

  .intensity-button {
    min-height: 48px;
  }

  .dock-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .history-message {
    grid-template-columns: auto 1fr;
  }

  .return-today-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 430px) {
  .app-shell {
    width: calc(100% - 16px);
  }

  .chart-card {
    border-radius: 18px;
  }

  .today-button {
    padding: 0 9px;
  }

  .date-copy strong {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .entry-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .entry-direction {
    gap: 5px;
    font-size: 9px;
  }

  .direction-arrow {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
