:root {
  color-scheme: light;
  --canvas: #f2f4f6;
  --surface: #ffffff;
  --surface-subtle: #f7f9fa;
  --ink: #17222d;
  --ink-soft: #4e5c68;
  --line: #d5dde3;
  --line-strong: #9cabb6;
  --accent: #0b67c2;
  --accent-strong: #074b8f;
  --accent-soft: #e3f1fb;
  --water: #168bbd;
  --water-light: #66c7df;
  --success: #147456;
  --success-soft: #e2f3ec;
  --danger: #a32b37;
  --danger-soft: #fae9eb;
  --focus: #ffbf47;
  --radius-panel: 16px;
  --radius-control: 10px;
  --z-sticky: 20;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: calc(var(--z-sticky) + 1);
  padding: 10px 14px;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  transform: translate(-50%, -150%);
  transition: transform 180ms ease-out;
}

.skip-link:focus {
  transform: translate(-50%, 0);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  border-bottom: 1px solid var(--line);
  background: rgba(242, 244, 246, 0.96);
  backdrop-filter: blur(10px);
}

.header-inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  min-width: 46px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 1.08rem;
  line-height: 1.25;
}

.brand p {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

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

.language-control select,
.quiet-button {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
}

.language-control select {
  min-width: 84px;
  padding: 0 30px 0 10px;
}

.quiet-button {
  padding: 0 13px;
  font-weight: 700;
}

.settings-short {
  display: none;
}

.quiet-button:hover,
.language-control select:hover {
  border-color: var(--ink-soft);
}

.app-frame {
  width: min(1180px, calc(100% - 40px));
  margin: 28px auto 64px;
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(320px, 0.82fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.today-workspace {
  min-width: 0;
  padding: 34px 38px 40px;
}

.insights-panel {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--surface-subtle);
}

.today-intro,
.section-heading,
.custom-form-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.date-line {
  margin: 0 0 4px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.today-intro h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.goal-chip {
  margin: 0;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 750;
  white-space: nowrap;
}

.progress-layout {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  align-items: center;
  gap: 38px;
}

.hydration-meter {
  --progress: 0%;
  position: relative;
  width: 190px;
  height: 340px;
  padding-left: 34px;
}

.meter-scale {
  position: absolute;
  inset: 0 auto 0 0;
  width: 30px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 0 9px;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.meter-scale span::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1px;
  margin-left: 4px;
  vertical-align: middle;
  background: var(--line-strong);
}

.meter-chamber {
  position: relative;
  height: 100%;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 14px 14px 8px 8px;
  background:
    linear-gradient(to bottom, transparent 24.75%, var(--line) 25%, transparent 25.25%),
    linear-gradient(to bottom, transparent 49.75%, var(--line) 50%, transparent 50.25%),
    linear-gradient(to bottom, transparent 74.75%, var(--line) 75%, transparent 75.25%),
    #f9fbfc;
}

.meter-fill {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--progress);
  background: var(--water);
  transition: height 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.meter-fill::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 5px;
  background: var(--water-light);
}

.meter-readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  mix-blend-mode: multiply;
}

.meter-readout strong {
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.03em;
}

.meter-readout span {
  margin-top: 7px;
  font-size: 0.84rem;
  font-weight: 700;
}

.hydration-meter[data-complete="true"] .meter-chamber {
  border-color: var(--success);
}

.hydration-meter[data-complete="true"] .meter-fill {
  background: var(--success);
}

.progress-copy {
  min-width: 0;
}

.state-copy {
  max-width: 60ch;
}

.state-copy h3 {
  margin: 0;
  font-size: 1.38rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.state-copy p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  text-wrap: pretty;
}

.today-stats {
  margin: 24px 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid var(--line);
}

.today-stats div {
  min-width: 0;
  padding: 14px 12px;
}

.today-stats div:first-child {
  padding-left: 0;
}

.today-stats div + div {
  border-left: 1px solid var(--line);
}

.today-stats dt {
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.today-stats dd {
  margin: 3px 0 0;
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.quick-log {
  min-width: 0;
  margin: 24px 0 0;
  padding: 0;
  border: 0;
}

.quick-log legend {
  margin-bottom: 10px;
  padding: 0;
  font-size: 0.88rem;
  font-weight: 800;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.amount-button {
  min-height: 72px;
  padding: 10px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  text-align: left;
  transition:
    border-color 160ms ease-out,
    background-color 160ms ease-out,
    transform 160ms ease-out;
}

.amount-button strong,
.amount-button span {
  display: block;
}

.amount-button strong {
  color: var(--accent-strong);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.amount-button > span {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.69rem;
  line-height: 1.25;
}

.amount-button > span span {
  display: inline;
}

.amount-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.amount-button:active {
  transform: translateY(1px);
}

.custom-button strong {
  font-size: 1.22rem;
}

.custom-form {
  margin-top: 12px;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface-subtle);
}

.custom-form-heading h3 {
  margin: 0;
  font-size: 0.96rem;
}

.form-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 10px;
}

.form-row label,
.goal-form label {
  display: grid;
  gap: 5px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 700;
}

.input-with-unit {
  min-width: 0;
  height: 42px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
}

.input-with-unit input {
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0 4px 0 11px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.input-with-unit > span {
  padding: 0 10px 0 5px;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.form-row select {
  width: 100%;
  height: 42px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
}

.primary-button,
.danger-button,
.text-button {
  border: 0;
  border-radius: var(--radius-control);
  font-weight: 750;
}

.primary-button {
  min-height: 42px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
}

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

.text-button {
  padding: 5px 7px;
  background: transparent;
  color: var(--accent-strong);
}

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

.form-error {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 700;
}

.action-feedback {
  min-height: 40px;
  margin-top: 10px;
  padding: 8px 10px 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: var(--radius-control);
  background: var(--success-soft);
  color: #0a5d43;
  font-size: 0.85rem;
  font-weight: 700;
}

.entry-section {
  margin-top: 34px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.section-heading > span {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.empty-entries {
  margin: 14px 0 0;
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.entry-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.entry-row {
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 32px;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.entry-identity {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.entry-kind {
  font-size: 0.88rem;
  font-weight: 750;
}

.entry-time {
  color: var(--ink-soft);
  font-size: 0.74rem;
}

.entry-amount {
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.entry-remove {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.15rem;
}

.entry-remove:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.insight-section {
  padding: 28px;
}

.insight-section + .insight-section {
  border-top: 1px solid var(--line);
}

.insight-section > h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.insight-section > p {
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  text-wrap: pretty;
}

.week-chart {
  height: 158px;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
  list-style: none;
}

.week-day {
  min-width: 0;
  display: grid;
  grid-template-rows: 22px minmax(0, 1fr) 22px;
  align-items: end;
  text-align: center;
}

.week-value {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

.week-track {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 6px 6px 3px 3px;
  background: #e1e6ea;
}

.week-bar {
  --bar-height: 0%;
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--bar-height);
  min-height: 0;
  background: var(--water);
  transition: height 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.week-day[data-met="true"] .week-bar {
  background: var(--success);
}

.week-label {
  align-self: end;
  padding-top: 6px;
  color: var(--ink-soft);
  font-size: 0.68rem;
  white-space: nowrap;
}

.week-day[data-today="true"] .week-label {
  color: var(--accent-strong);
  font-weight: 800;
}

.goal-section > p {
  max-width: 42ch;
}

.goal-form {
  margin-top: 16px;
}

.goal-input-row {
  margin-top: 6px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.goal-presets {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.goal-presets button {
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.goal-presets button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.safety-note {
  padding: 10px 11px;
  border-radius: 10px;
  background: #eef1f3;
  color: var(--ink) !important;
}

.source-links {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.source-links a {
  width: fit-content;
  font-size: 0.76rem;
  font-weight: 700;
  text-underline-offset: 3px;
}

.data-section {
  padding-bottom: 34px;
}

.danger-button {
  width: 100%;
  min-height: 40px;
  margin-top: 16px;
  padding: 7px 12px;
  background: var(--danger-soft);
  color: var(--danger);
}

.danger-button:hover {
  background: #f4d7da;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.input-with-unit:focus-within {
  border-color: var(--accent);
  outline: 2px solid rgba(11, 103, 194, 0.18);
}

@media (max-width: 900px) {
  .header-inner {
    padding-left: 82px;
  }

  .app-frame {
    grid-template-columns: 1fr;
  }

  .insights-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .insights-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .insight-section:nth-child(even) {
    border-left: 1px solid var(--line);
  }

  .insight-section + .insight-section {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 680px) {
  .header-inner,
  .app-frame {
    width: min(100% - 24px, 1180px);
  }

  .header-inner {
    min-height: 64px;
  }

  .brand p {
    display: none;
  }

  .brand-mark {
    display: none;
  }

  .brand h1 {
    font-size: 0.96rem;
    white-space: nowrap;
  }

  .quiet-button {
    min-width: 48px;
    padding: 0 10px;
  }

  .settings-long {
    display: none;
  }

  .settings-short {
    display: inline;
  }

  .app-frame {
    margin-top: 12px;
    margin-bottom: 30px;
  }

  .today-workspace {
    padding: 24px 18px 30px;
  }

  .today-intro {
    align-items: flex-end;
  }

  .today-intro h2 {
    font-size: 1.65rem;
  }

  .goal-chip {
    max-width: 54%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .progress-layout {
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: start;
    gap: 18px;
  }

  .hydration-meter {
    width: 112px;
    height: 260px;
    padding-left: 27px;
  }

  .meter-scale {
    width: 24px;
    font-size: 0.6rem;
  }

  .meter-scale span::after {
    width: 4px;
    margin-left: 2px;
  }

  .meter-readout strong {
    font-size: 1.35rem;
  }

  .meter-readout span {
    font-size: 0.68rem;
  }

  .state-copy h3 {
    font-size: 1.08rem;
  }

  .state-copy p {
    font-size: 0.82rem;
  }

  .today-stats {
    grid-template-columns: 1fr;
    margin-top: 16px;
  }

  .today-stats div,
  .today-stats div:first-child {
    padding: 8px 0;
  }

  .today-stats div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .quick-log {
    grid-column: 1 / -1;
    margin-left: -130px;
    padding-left: 130px;
  }

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

  .custom-form,
  .action-feedback {
    grid-column: 1 / -1;
    margin-left: -130px;
  }

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

  .form-row .primary-button {
    grid-column: 1 / -1;
  }

  .insights-panel {
    display: block;
  }

  .insight-section {
    padding: 24px 18px;
  }

  .insight-section:nth-child(even) {
    border-left: 0;
  }
}

@media (max-width: 420px) {
  .language-control select {
    min-width: 66px;
    width: 66px;
  }

  .progress-layout {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 14px;
  }

  .hydration-meter {
    width: 96px;
    padding-left: 23px;
  }

  .quick-log {
    margin-left: -110px;
    padding-left: 110px;
  }

  .custom-form,
  .action-feedback {
    margin-left: -110px;
  }

  .entry-row {
    gap: 8px;
  }

  .entry-identity {
    display: grid;
    gap: 0;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .app-header {
    position: relative;
  }

  .app-frame {
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
    margin-top: 12px;
  }

  .today-workspace {
    padding-top: 22px;
  }

  .progress-layout {
    grid-template-columns: 126px minmax(0, 1fr);
    align-items: start;
    gap: 20px;
  }

  .hydration-meter {
    width: 126px;
    height: 220px;
    padding-left: 27px;
  }

  .insights-panel {
    display: block;
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .insight-section:nth-child(even) {
    border-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
