/* ============================================================
   起 · 一页 — start page
   tokens → layers → topbar → stage → search → shelf → drawer
   ============================================================ */

@property --wash-h {
  syntax: "<number>";
  inherits: true;
  initial-value: 205;
}

:root {
  transition: --wash-h 3s linear;
  --font-ui: "Optima", "HarmonyOS Sans SC", "PingFang SC", "MiSans", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Palatino", "Georgia", "Songti SC", "Source Han Serif SC", "SimSun", serif;

  --bg: #f2f5f6;
  --ink: #16232b;
  --ink-soft: #475862;
  --muted: #78888f;
  --line: rgba(22, 35, 43, 0.12);
  --line-strong: rgba(22, 35, 43, 0.28);
  --accent: #2e6c87;
  --danger: #9c3b2c;
  --panel: #fafcfc;
  --tile: rgba(255, 255, 255, 0.5);
  --tile-hover: rgba(255, 255, 255, 0.92);
  --sel: rgba(46, 108, 135, 0.16);
  --shadow-drawer: -34px 0 90px -50px rgba(10, 22, 28, 0.55);
  --shadow-menu: 0 26px 60px -30px rgba(12, 24, 31, 0.35), 0 2px 10px -6px rgba(12, 24, 31, 0.25);
  --shadow-tile: 0 16px 30px -20px rgba(16, 30, 38, 0.5);

  --gutter: clamp(22px, 3vw, 40px);
  --wash-h: 205;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0d1419;
  --ink: #e7eef2;
  --ink-soft: #b2c1ca;
  --muted: #7b8c96;
  --line: rgba(205, 225, 236, 0.14);
  --line-strong: rgba(205, 225, 236, 0.32);
  --accent: #86bfd4;
  --danger: #d99a8b;
  --panel: #141d23;
  --tile: rgba(255, 255, 255, 0.045);
  --tile-hover: rgba(255, 255, 255, 0.085);
  --sel: rgba(134, 191, 212, 0.22);
  --shadow-drawer: -40px 0 100px -40px rgba(0, 0, 0, 0.85);
  --shadow-menu: 0 30px 70px -30px rgba(0, 0, 0, 0.9), 0 2px 10px -6px rgba(0, 0, 0, 0.7);
  --shadow-tile: 0 18px 34px -22px rgba(0, 0, 0, 0.9);

  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1000px 700px at 82% -10%, hsl(calc(var(--wash-h) + 10) 44% 85% / 0.62), transparent 68%),
    radial-gradient(840px 640px at 6% 108%, hsl(calc(var(--wash-h) - 22) 38% 83% / 0.55), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

[data-theme="dark"] body {
  background:
    radial-gradient(1050px 720px at 82% -12%, hsl(calc(var(--wash-h) + 10) 44% 22% / 0.8), transparent 70%),
    radial-gradient(820px 640px at 6% 108%, hsl(calc(var(--wash-h) - 24) 40% 17% / 0.75), transparent 72%),
    var(--bg);
  background-attachment: fixed;
}

h1, h2, h3, p { margin: 0; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

input { font: inherit; color: inherit; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--sel); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- atmosphere ---------- */

.grain {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0.06;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

[data-theme="dark"] .grain { opacity: 0.07; }

/* ---------- topbar ---------- */

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(16px, 3vh, 30px) var(--gutter) 0;
  animation: fade 0.9s ease both;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.2em;
  color: var(--ink);
  transition: opacity 0.2s;
}

.brand span {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.34em;
  color: var(--muted);
}

.brand:hover { opacity: 0.68; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.weather {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin-right: 4px;
  padding: 0 12px 0 8px;
  border-radius: 999px;
  color: var(--ink-soft);
  transition: background 0.2s ease, color 0.2s ease;
}

.weather:hover {
  background: var(--tile);
  color: var(--ink);
}

.weather-icon {
  display: grid;
  place-items: center;
  color: var(--accent);
}

.weather-icon svg { width: 18px; height: 18px; }

.weather-temp {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.weather-desc {
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-soft);
  transition: background 0.22s ease, color 0.22s ease;
}

.icon-btn svg { width: 19px; height: 19px; }

.icon-btn:hover {
  background: var(--tile);
  color: var(--ink);
}

.ic-moon { display: none; }
[data-theme="dark"] .ic-sun { display: none; }
[data-theme="dark"] .ic-moon { display: block; }

/* ---------- stage ---------- */

.stage {
  position: relative;
  z-index: 2;
  width: min(760px, 100%);
  margin: 0 auto;
  padding:
    clamp(100px, 16vh, 158px)
    24px
    clamp(56px, 8vh, 76px);
}

.greeting {
  display: flex;
  align-items: center;
  gap: 13px;
  font-size: 12.5px;
  letter-spacing: 0.3em;
  color: var(--ink-soft);
  animation: rise 0.7s 0.05s cubic-bezier(0.16, 0.84, 0.28, 1) both;
}

.greeting::before {
  content: "";
  width: 30px;
  height: 1px;
  background: var(--line-strong);
}

.clock {
  display: flex;
  align-items: baseline;
  margin-top: 12px;
  margin-left: -0.055em;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(4.2rem, 13vw, 9rem);
  line-height: 0.94;
  letter-spacing: -0.015em;
  font-feature-settings: "kern" 1;
  animation: rise 0.85s 0.12s cubic-bezier(0.16, 0.84, 0.28, 1) both;
}

.clock .colon {
  opacity: 0.55;
  margin: 0 0.015em;
}

.clock .ss {
  margin-left: 0.55em;
  font-family: var(--font-ui);
  font-size: clamp(11px, 1.15vw, 14px);
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.dayline {
  position: relative;
  width: min(400px, 66%);
  height: 1px;
  margin-top: clamp(22px, 3.6vh, 36px);
  background: var(--line);
  animation: rise 0.85s 0.2s cubic-bezier(0.16, 0.84, 0.28, 1) both;
}

.dayline-dot {
  position: absolute;
  top: 50%;
  left: calc(var(--day, 0.5) * 100%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  transition: left 1s linear;
}

.date {
  margin-top: 16px;
  font-size: 13px;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  animation: rise 0.85s 0.26s cubic-bezier(0.16, 0.84, 0.28, 1) both;
}

/* ---------- search ---------- */

.search {
  position: relative;
  display: flex;
  align-items: center;
  height: 58px;
  margin-top: clamp(34px, 5.6vh, 56px);
  border-bottom: 1.5px solid var(--line-strong);
  transition: border-color 0.25s ease;
  animation: rise 0.85s 0.34s cubic-bezier(0.16, 0.84, 0.28, 1) both;
}

.search:hover { border-color: var(--ink-soft); }
.search:focus-within { border-color: var(--ink); }

.engine {
  flex: none;
  width: 44px;
  height: 44px;
  margin-left: -10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--accent);
  transition: background 0.2s ease;
}

.engine:hover { background: var(--tile); }

.search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-family: var(--font-ui);
  font-size: clamp(16px, 1.6vw, 19px);
  letter-spacing: 0.015em;
}

.search-input::placeholder { color: var(--muted); opacity: 0.85; }

.enter-hint {
  flex: none;
  margin-right: 3px;
  padding: 2px 6px;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: opacity 0.2s ease;
}

.search.has-value .enter-hint { opacity: 0; }

/* ---------- engine menu ---------- */

.engine-menu {
  position: absolute;
  top: calc(100% + 12px);
  left: -10px;
  z-index: 30;
  min-width: 224px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-menu);
  animation: menuIn 0.18s ease both;
}

.engine-menu[hidden] { display: none; }

.engine-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease;
}

.engine-item .g {
  width: 20px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--accent);
}

.engine-item:hover { background: var(--tile-hover); color: var(--ink); }

.engine-item[aria-selected="true"] {
  background: var(--tile);
  color: var(--ink);
}

.engine-item .check {
  margin-left: auto;
  width: 14px;
  height: 14px;
  opacity: 0;
}

.engine-item[aria-selected="true"] .check { opacity: 1; }

/* ---------- shelf ---------- */

.shelf {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px 10px;
  max-width: 100%;
  margin-top: clamp(36px, 6.2vh, 58px);
  animation: rise 0.85s 0.44s cubic-bezier(0.16, 0.84, 0.28, 1) both;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: 100%;
  max-width: 124px;
  justify-self: center;
  padding: 12px 4px;
  border-radius: 14px;
}

.tile-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--tile);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.24, 1), background 0.22s, border-color 0.22s, box-shadow 0.22s;
}

[data-theme="dark"] .tile-icon { box-shadow: none; }

.tile-icon img {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

[data-theme="dark"] .tile-icon img {
  width: 30px;
  height: 30px;
  padding: 2px;
  border-radius: 8px;
  background: #e3eaee;
}

.tile .mono {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
}

.tile-name {
  max-width: 100%;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.18s ease;
}

.tile:hover .tile-icon {
  transform: translateY(-3px);
  background: var(--tile-hover);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-tile);
}

.tile:hover .tile-name { color: var(--ink); }

.add-link {
  display: flex;
  align-items: center;
  gap: 7px;
  width: max-content;
  margin: 16px auto 0;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
  transition: color 0.2s ease, background 0.2s ease;
}

.add-link svg {
  width: 13px;
  height: 13px;
  transition: transform 0.22s ease;
}

.add-link:hover {
  color: var(--ink);
  background: var(--tile);
}

.add-link:hover svg { transform: rotate(90deg); }

/* ---------- footer ---------- */

.foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 0 var(--gutter) clamp(16px, 3vh, 26px);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
  pointer-events: none;
}

kbd {
  display: inline-block;
  margin-right: 7px;
  padding: 2px 6px;
  font-family: var(--font-ui);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}

/* ---------- scrim / drawer ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(9, 17, 22, 0.26);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.scrim.on {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: min(440px, 94vw);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-drawer);
  transform: translateX(102%);
  transition: transform 0.4s cubic-bezier(0.22, 0.9, 0.24, 1);
  visibility: hidden;
}

.drawer.on {
  transform: none;
  visibility: visible;
}

.drawer-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px 26px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 0.18em;
  color: var(--ink);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 26px 46px;
}

.drawer-body::-webkit-scrollbar { width: 8px; }
.drawer-body::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
  border: 2px solid var(--panel);
}

.group { padding-top: 26px; }

.group h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3em;
  color: var(--muted);
}

.group h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 18px;
}

.field-label {
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.seg {
  display: inline-flex;
  align-self: flex-start;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.seg button {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: background 0.18s ease, color 0.18s ease;
}

.seg button:hover { color: var(--ink); }

.seg button[aria-checked="true"] {
  background: var(--ink);
  color: var(--bg);
}

.section-note {
  margin: -4px 0 14px;
  font-size: 11.5px;
  line-height: 1.75;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.section-note.flash { color: var(--accent); }

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

.text-input {
  width: 100%;
  height: 38px;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  outline: none;
  font-size: 13px;
  letter-spacing: 0.03em;
  transition: border-color 0.2s ease;
}

.text-input::placeholder { color: var(--muted); opacity: 0.75; }

.text-input:focus { border-bottom-color: var(--ink); }

.city-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 12px;
}

/* ---------- shortcut editor ---------- */

.editor { display: flex; flex-direction: column; }

.row {
  display: grid;
  grid-template-columns: 16px 30px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  border-radius: 6px;
  transition: opacity 0.18s;
}

.row.dragging { opacity: 0.35; }

.row.drop-target { box-shadow: inset 0 2px 0 var(--accent); }

.handle {
  width: 16px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: 4px;
  cursor: grab;
}

.handle:active { cursor: grabbing; }

.handle svg { width: 12px; height: 18px; }

.row-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--tile);
}

.row-icon img { width: 16px; height: 16px; border-radius: 3px; }

[data-theme="dark"] .row-icon img {
  width: 22px;
  height: 22px;
  padding: 2px;
  background: #e9eef1;
  border-radius: 4px;
}

.row-icon .mono {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--ink);
  line-height: 1;
}

.row-fields {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row-name,
.row-url {
  width: 100%;
  padding: 2px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  outline: none;
  font-family: var(--font-ui);
  transition: border-color 0.2s ease;
}

.row-name {
  font-size: 13px;
  letter-spacing: 0.03em;
  color: var(--ink);
}

.row-url {
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.row-name:focus,
.row-url:focus { border-bottom-color: var(--line-strong); }

.row-name::placeholder,
.row-url::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.row-del {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  opacity: 0.5;
  transition: opacity 0.18s, color 0.18s, background 0.18s;
}

.row-del svg { width: 14px; height: 14px; }

.row:hover .row-del { opacity: 1; }

.row-del:hover {
  color: var(--danger);
  background: var(--tile);
}

.ghost-btn {
  width: 100%;
  height: 40px;
  margin-top: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.ghost-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--tile);
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.line-btn {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.line-btn:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
  background: var(--tile);
}

.line-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.line-btn:disabled:hover {
  color: var(--ink-soft);
  border-color: var(--line-strong);
  background: transparent;
}

.line-btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 38%, transparent);
}

.line-btn.danger:hover {
  background: color-mix(in srgb, var(--danger) 9%, transparent);
}

/* ---------- motion ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .stage {
    padding: 100px 22px 108px;
  }

  .topbar {
    padding: 14px 14px 0 14px;
  }

  .brand { margin-left: 8px; }

  .foot {
    padding: 0 22px 18px;
    gap: 18px;
  }

  .shelf {
    gap: 16px 6px;
  }

  .tile-icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
  }
}

@media (max-width: 520px) {
  .clock { font-size: 4.15rem; }
  .clock .ss { margin-left: 0.4em; }
  .dayline { width: 78%; }
  .enter-hint { display: none; }
  .foot .hint:last-child { display: none; }
  .drawer-body { padding: 2px 20px 40px; }
  .drawer-head { padding-left: 20px; }
  .seg button { padding: 0 12px; }
}

@media (max-width: 340px) {
  .weather {
    gap: 6px;
    padding: 0 6px;
    margin-right: 0;
  }

  .weather-desc { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}
