:root {
  --font-sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  --font-display: "DIN Alternate", "Avenir Next Condensed", "PingFang SC", sans-serif;

  --bg-base: #f5eee6;
  --bg-tint: #fff8ef;
  --card: rgba(255, 255, 255, 0.84);
  --card-strong: rgba(255, 255, 255, 0.96);
  --text: #141920;
  --muted: #5c6774;
  --line: rgba(20, 25, 32, 0.13);

  --pomodoro: #d44f2f;
  --pomodoro-soft: #f18a63;
  --meditation: #1b845b;
  --meditation-soft: #75cd9f;
  --accent-navy: #2d3f55;

  --ok: #187f43;
  --ok-bg: rgba(225, 247, 234, 0.96);
  --err: #982b24;
  --err-bg: rgba(255, 234, 229, 0.96);

  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 12px;

  --shadow-soft: 0 18px 40px rgba(19, 25, 34, 0.11);
  --shadow-strong: 0 28px 60px rgba(19, 25, 34, 0.18);
}

body[data-theme="dark"] {
  --bg-base: #0d1117;
  --bg-tint: #151b22;
  --card: rgba(24, 31, 40, 0.84);
  --card-strong: rgba(29, 36, 46, 0.96);
  --text: #f5f8fb;
  --muted: #a8b4c1;
  --line: rgba(255, 255, 255, 0.11);
  --ok-bg: rgba(32, 91, 54, 0.5);
  --err-bg: rgba(117, 40, 40, 0.52);
  --shadow-soft: 0 24px 48px rgba(0, 0, 0, 0.38);
  --shadow-strong: 0 36px 74px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  overflow-x: hidden;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    linear-gradient(160deg, var(--bg-tint) 0%, var(--bg-base) 65%),
    repeating-linear-gradient(
      -38deg,
      rgba(255, 255, 255, 0.06) 0,
      rgba(255, 255, 255, 0.06) 2px,
      transparent 2px,
      transparent 22px
    );
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -2;
  width: 46vw;
  height: 46vw;
  min-width: 360px;
  min-height: 360px;
  border-radius: 50%;
  filter: blur(56px);
  opacity: 0.33;
}

body::before {
  top: -16vw;
  left: -14vw;
  background: radial-gradient(circle, rgba(212, 79, 47, 0.62), transparent 66%);
  animation: driftA 16s ease-in-out infinite alternate;
}

body::after {
  right: -14vw;
  top: -10vw;
  background: radial-gradient(circle, rgba(27, 132, 91, 0.6), transparent 70%);
  animation: driftB 18s ease-in-out infinite alternate;
}

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

#app {
  width: 100%;
}

.shell {
  width: min(1260px, calc(100% - 42px));
  margin: 26px auto 40px;
}

.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 26px 16px;
}

.auth-card {
  width: min(560px, 100%);
  padding: 34px 30px 28px;
  border-radius: var(--radius-xl);
  background: var(--card);
  border: 1px solid transparent;
  background-image:
    linear-gradient(var(--card), var(--card)),
    linear-gradient(132deg, rgba(212, 79, 47, 0.44), rgba(27, 132, 91, 0.38));
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(14px);
  animation: liftIn 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.brand-badge {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 30px;
  color: #fff;
  background: linear-gradient(138deg, var(--pomodoro), var(--meditation));
  box-shadow: 0 16px 32px rgba(19, 25, 34, 0.28);
}

.brand-title {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  font-size: clamp(28px, 4.8vw, 44px);
  line-height: 1;
}

.brand-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.form-grid {
  display: grid;
  gap: 13px;
  margin-top: 22px;
}

.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  background: var(--card-strong);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input:focus {
  outline: none;
  border-color: rgba(212, 79, 47, 0.58);
  box-shadow: 0 0 0 4px rgba(212, 79, 47, 0.16);
}

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

.row.wrap {
  flex-wrap: wrap;
}

.space {
  justify-content: space-between;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.17s ease, box-shadow 0.17s ease, filter 0.17s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(130deg, var(--pomodoro-soft), var(--pomodoro));
  box-shadow: 0 14px 26px rgba(212, 79, 47, 0.35);
}

.btn-secondary {
  color: var(--text);
  background: var(--card-strong);
  border: 1px solid var(--line);
}

.btn-green {
  color: #fff;
  background: linear-gradient(130deg, var(--meditation-soft), var(--meditation));
  box-shadow: 0 14px 26px rgba(27, 132, 91, 0.32);
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--pomodoro);
  cursor: pointer;
  padding: 0;
  font-weight: 700;
}

.top-card {
  position: relative;
  overflow: hidden;
  padding: 30px 28px 22px;
  border-radius: var(--radius-xl);
  border: 1px solid transparent;
  background-image:
    linear-gradient(var(--card), var(--card)),
    linear-gradient(136deg, rgba(212, 79, 47, 0.5), rgba(37, 78, 126, 0.4), rgba(27, 132, 91, 0.48));
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(14px);
  animation: liftIn 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.top-card::after {
  content: "";
  position: absolute;
  right: -18%;
  top: -48%;
  width: 48%;
  height: 180%;
  transform: rotate(18deg);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.24),
    rgba(255, 255, 255, 0)
  );
  pointer-events: none;
}

.top-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.top-eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.top-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(38px, 6.2vw, 58px);
  line-height: 0.95;
  letter-spacing: 0.07em;
}

.top-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.user-pill {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-strong);
  box-shadow: 0 10px 20px rgba(19, 25, 34, 0.12);
  font-size: 13px;
  font-weight: 600;
}

#headerMeta {
  margin-top: 18px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.meta-chip {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.45));
}

.meta-label {
  color: var(--muted);
  font-size: 12px;
}

.meta-value {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0.03em;
}

.tab-bar {
  margin-top: 16px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.25);
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab-btn {
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.42);
}

.tab-btn.active {
  color: #fff;
  box-shadow: 0 10px 18px rgba(19, 25, 34, 0.22);
}

.tab-btn.active[data-tab="pomodoro"] {
  background: linear-gradient(130deg, var(--pomodoro-soft), var(--pomodoro));
}

.tab-btn.active[data-tab="meditation"] {
  background: linear-gradient(130deg, var(--meditation-soft), var(--meditation));
}

.tab-btn.active[data-tab="stats"],
.tab-btn.active[data-tab="settings"] {
  background: linear-gradient(130deg, #47607f, var(--accent-navy));
}

.page-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  grid-column: span 12;
  padding: 26px;
  border-radius: var(--radius-xl);
  border: 1px solid transparent;
  background-image:
    linear-gradient(var(--card), var(--card)),
    linear-gradient(145deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.16));
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.panel h2,
.panel h3 {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 34px);
  line-height: 1.1;
}

.panel-subtitle {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.info-cards {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 12px;
}

.info-card {
  padding: 15px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--card-strong);
}

.info-card-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.info-card-value {
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: clamp(30px, 3.4vw, 42px);
  line-height: 0.95;
  letter-spacing: 0.03em;
}

.timer-shell {
  position: relative;
  width: min(360px, 82vw);
  margin: 26px auto 18px;
  display: grid;
  place-items: center;
}

.timer-shell::before {
  content: "";
  position: absolute;
  inset: -22px;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.94);
}

.timer-shell.mode-pomodoro::before {
  background: radial-gradient(circle, rgba(212, 79, 47, 0.24), transparent 68%);
}

.timer-shell.mode-meditation::before {
  background: radial-gradient(circle, rgba(27, 132, 91, 0.24), transparent 68%);
}

.timer-shell.is-running::before {
  opacity: 1;
  animation: pulseAura 2.6s ease-in-out infinite;
}

.timer-ring {
  width: 100%;
  aspect-ratio: 1;
  transform: rotate(-90deg);
}

.timer-ring-track {
  fill: none;
  stroke: rgba(112, 125, 141, 0.24);
  stroke-width: 14;
}

.timer-ring-progress {
  fill: none;
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.24s linear;
  filter: drop-shadow(0 6px 10px rgba(18, 24, 34, 0.24));
}

.timer-ring-progress.pomodoro {
  stroke: url(#gradPomodoro);
}

.timer-ring-progress.meditation {
  stroke: url(#gradMeditation);
}

.timer-time {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: clamp(52px, 9vw, 74px);
  letter-spacing: 0.06em;
}

.timer-note {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.history-list,
.meditation-list {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.history-item,
.meditation-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--card-strong);
  display: grid;
  gap: 5px;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.history-item:hover,
.meditation-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(19, 25, 34, 0.14);
}

.item-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.item-title {
  font-weight: 700;
  font-size: 15px;
}

.item-time {
  color: var(--muted);
  font-size: 13px;
}

.section-title {
  margin: 0;
  font-size: 24px;
}

.chips {
  margin: 18px 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--card-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.chip.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(130deg, var(--meditation-soft), var(--meditation));
}

.message {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 14px;
}

.message.ok {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: rgba(24, 127, 67, 0.3);
}

.message.err {
  color: var(--err);
  background: var(--err-bg);
  border-color: rgba(152, 43, 36, 0.34);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 7, 12, 0.52);
  backdrop-filter: blur(3px);
}

.modal {
  width: min(460px, 100%);
  padding: 24px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--card-strong);
  box-shadow: var(--shadow-strong);
}

.modal h3 {
  margin: 0 0 10px;
  font-size: 28px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100% - 28px));
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--card-strong);
  box-shadow: var(--shadow-soft);
  display: none;
  z-index: 120;
}

.year-switch {
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.25);
}

.chart-wrap {
  margin-top: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--card-strong);
  overflow: hidden;
}

.chart-grid {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.chart-grid.chart-grid-single {
  grid-template-columns: 1fr;
}

.chart-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.chart-note-inline {
  margin: 12px 14px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.chart-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.chart-peak {
  font-size: 13px;
  color: var(--muted);
}

.chart-svg {
  width: 100%;
  height: 260px;
  display: block;
}

.chart-svg-full-history {
  height: 442px;
}

.chart-plot-bg {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-grid-line {
  stroke: var(--line);
  stroke-opacity: 0.68;
  stroke-width: 1;
}

.chart-main-line {
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 4px 12px rgba(212, 79, 47, 0.32));
}

.chart-sub-dot {
  fill: var(--pomodoro);
  opacity: 0.45;
}

.chart-focus-dot {
  fill: var(--card-strong);
  stroke: var(--pomodoro);
  stroke-width: 2.2;
  filter: drop-shadow(0 2px 6px rgba(212, 79, 47, 0.36));
}

.chart-focus-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  fill: var(--text);
  paint-order: stroke;
  stroke: var(--card-strong);
  stroke-width: 4;
  stroke-linejoin: round;
}

.chart-latest-guide {
  stroke: var(--pomodoro);
  stroke-opacity: 0.28;
  stroke-width: 1.2;
  stroke-dasharray: 4 6;
}

.chart-x-label {
  font-family: var(--font-sans);
  font-size: 11px;
  fill: var(--muted);
}

.chart-empty {
  margin: 14px;
  color: var(--muted);
  font-size: 14px;
}

.full-history-wrap {
  margin-top: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0));
}

.chart-point-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  paint-order: stroke;
  stroke: var(--card-strong);
  stroke-width: 3;
  stroke-linejoin: round;
}

.chart-y-label {
  font-family: var(--font-sans);
  font-size: 11px;
  fill: var(--muted);
}

body[data-theme="dark"] .chart-main-line {
  filter: drop-shadow(0 5px 12px rgba(212, 79, 47, 0.42));
}

body[data-theme="dark"] .chart-focus-label {
  fill: #f2f5f8;
  stroke: #1a2430;
}

.legend {
  display: flex;
  gap: 14px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 7px;
}

.settings-grid {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.settings-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card-strong);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

@keyframes driftA {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(40px, 26px) scale(1.06);
  }
}

@keyframes driftB {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(-34px, 20px) scale(1.05);
  }
}

@keyframes pulseAura {
  0% {
    transform: scale(0.9);
    opacity: 0.2;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.34;
  }
  100% {
    transform: scale(0.9);
    opacity: 0.2;
  }
}

@keyframes liftIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 1120px) {
  .page-grid .panel-half:first-child {
    grid-column: span 7;
  }

  .page-grid .panel-half:last-child {
    grid-column: span 5;
  }

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

@media (max-width: 980px) {
  .shell {
    width: calc(100% - 24px);
  }

  .top-card {
    padding: 24px 20px 18px;
  }

  .panel {
    padding: 20px;
  }

  .meta-value {
    font-size: 24px;
  }
}

@media (max-width: 700px) {
  .shell {
    width: calc(100% - 14px);
    margin-top: 10px;
  }

  .auth-card {
    padding: 26px 18px 20px;
    border-radius: 20px;
  }

  .top-title {
    font-size: clamp(34px, 12vw, 46px);
  }

  .top-subtitle {
    font-size: 14px;
    line-height: 1.35;
  }

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

  .tab-bar {
    width: 100%;
    justify-content: flex-start;
  }

  .tab-btn {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
  }

  .panel {
    padding: 16px;
    border-radius: 18px;
  }

  .panel h2,
  .panel h3 {
    font-size: clamp(23px, 7vw, 30px);
  }

  .timer-shell {
    width: min(300px, 88vw);
    margin-top: 20px;
  }

  .timer-time {
    font-size: clamp(46px, 13vw, 62px);
  }

  .year-switch {
    width: 100%;
    justify-content: space-between;
  }

  .year-switch .btn {
    padding-inline: 14px;
  }
}
