/* 4-h.me 設計系統
   一條共用的版心（--edge）：頁首、綠色色塊、列表、單筆頁的左右邊都對齊它。
   操作畫面用綠色色塊（.band），瀏覽畫面用淡綠紙（.paper），兩邊共用同一套控件和同一種列（.entry）。
   協會的四葉草標誌平常是右側的小裝飾，只有訪客首頁放大；建立成功時彈出來（.band-bloom）是全站唯一的主動畫。
   顏色一律走下面的變數，深色模式只換變數。 */

:root {
  color-scheme: light;

  /* 品牌色，任何主題都不變 */
  --green: #0B7F43;
  --ink: #0C3B29;
  --white: #FFFFFF;
  --sun: #FFC83D;
  --sky: #8ED0F2;
  --coral: #FF9A7A;
  --mint: #A8DDB5;

  /* 隨主題變 */
  --bg: #FFFFFF;
  --text: #0C3B29;
  --muted: #47665A;
  --surface: #FFFFFF;
  --paper: #F3F6ED;
  --grid: #DCE5D3;
  --rule: #D5E0CE;
  --line: #6F8E7F;
  --tint: #EAF2E5;
  --accent: #0B7F43;
  --link-hover: #0B7F43;
  --bar: #0B7F43;
  --focus: #0C3B29;
  --error: #B4380F;
  --icon-moon: block;
  --icon-sun: none;

  --font-display: 'Huninn', 'Noto Sans TC', sans-serif;
  --font-note: 'LXGW WenKai TC', 'Noto Sans TC', serif;
  --font-body: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;

  --page: 1120px;
  --gutter: clamp(16px, 4vw, 40px);
  --edge: max(var(--gutter), calc(50% - var(--page) / 2));
  --r-ctl: 14px;
  --r-card: 20px;
  --ctl-h: 44px;

  --i-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='3'/%3E%3Cpath d='M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1'/%3E%3C/svg%3E");
  --i-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  --i-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.8-3.8'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12241A;
    --text: #E8F1E4;
    --muted: #AFC4B4;
    --surface: #1B3325;
    --paper: #12241A;
    --grid: #24402F;
    --rule: #2C4A38;
    --line: #6E9480;
    --tint: #1F3A2A;
    --accent: #A8DDB5;
    --link-hover: #FFC83D;
    --bar: #A8DDB5;
    --focus: #FFC83D;
    --error: #FFB199;
    --icon-moon: none;
    --icon-sun: block;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12241A;
  --text: #E8F1E4;
  --muted: #AFC4B4;
  --surface: #1B3325;
  --paper: #12241A;
  --grid: #24402F;
  --rule: #2C4A38;
  --line: #6E9480;
  --tint: #1F3A2A;
  --accent: #A8DDB5;
  --link-hover: #FFC83D;
  --bar: #A8DDB5;
  --focus: #FFC83D;
  --error: #FFB199;
  --icon-moon: none;
  --icon-sun: block;
}

/* 基礎 */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.25;
}

h2 {
  font-size: 22px;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-underline-offset: 4px;
}

a:hover {
  color: var(--link-hover);
}

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

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

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

::placeholder {
  color: var(--muted);
  opacity: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  --focus: var(--white);
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 10;
  padding: 10px 18px;
  color: var(--ink);
  background: var(--sun);
  border-radius: var(--r-ctl);
}

.skip-link:focus {
  top: 8px;
}

/* 頁首：每一頁的位置都一樣 */

.site-header {
  --focus: var(--white);
  padding: 10px var(--edge);
  color: var(--white);
  background: var(--green);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 4px 24px;
  min-height: 44px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 44px;
  color: var(--white);
  text-decoration: none;
}

.wordmark:hover {
  color: var(--white);
}

.wordmark-mark {
  flex: none;
  width: 30px;
  height: auto;
}

.site-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--ctl-h);
  padding: 0 14px;
  font-weight: 500;
  color: var(--white);
  text-decoration: none;
  border-radius: 12px;
  transition: background-color 120ms ease;
}

.nav-link:hover {
  color: var(--white);
  background: rgb(12 59 41 / 0.32);
}

.nav-link[aria-current="page"] {
  background: var(--ink);
}

.site-user {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin: 0 0 0 auto;
}

.site-user-name {
  max-width: 10em;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-logout {
  min-height: var(--ctl-h);
  padding: 0 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--white);
  background: none;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.site-logout:hover {
  background: rgb(12 59 41 / 0.32);
}

.theme-toggle {
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: auto;
  padding: 0;
  color: var(--white);
  background: rgb(12 59 41 / 0.28);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.site-user + .theme-toggle {
  margin-left: 0;
}

.theme-toggle:hover {
  background: rgb(12 59 41 / 0.5);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-moon {
  display: var(--icon-moon);
}

.icon-sun {
  display: var(--icon-sun);
}

.site-header > .flash {
  margin-top: 8px;
}

@media (max-width: 759.98px) {
  .site-header {
    padding-block: 6px 8px;
  }

  .site-header-inner {
    flex-wrap: wrap;
    gap: 0 4px;
  }

  .site-nav {
    order: 3;
    flex: 1 0 100%;
    margin-top: 2px;
  }

  .site-nav .nav-link {
    flex: 1 1 0;
    padding: 0 4px;
    font-size: 15px;
  }

  .site-user-name {
    display: none;
  }
}

/* 綠色色塊 */

.band {
  --link-hover: var(--white);
  --focus: var(--white);
  --ring: var(--sun);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px var(--edge) 32px;
  color: var(--white);
  background: var(--green);
}

.band > :not(.clover) {
  position: relative;
  max-width: 760px;
}

.band h1 {
  font-size: clamp(26px, 3.4vw, 38px);
}

.band-work {
  padding-bottom: 16px;
}

.clover {
  position: absolute;
  top: 50%;
  right: max(0px, calc(var(--edge) - 24px));
  width: 216px;
  height: auto;
  pointer-events: none;
  transform: translateY(-50%);
}

.band:has(+ .card) {
  padding-bottom: 84px;
}

.band:has(+ .card) .clover {
  top: 18px;
  width: 176px;
  transform: none;
}

/* 中等寬度以下：四葉草縮小放在標題那一行右邊，不壓到輸入框 */
@media (max-width: 1099.98px) {
  .clover, .band:has(+ .card) .clover {
    top: 12px;
    right: var(--gutter);
    width: 60px;
    transform: none;
  }

  .band h1 {
    max-width: calc(100% - 72px);
  }
}

/* 訪客、密碼、過期這類整頁只說一件事的畫面，四葉草才放大 */
.band-tall {
  justify-content: center;
  gap: 20px;
  min-height: min(560px, 62vh);
  padding-block: 48px;
}

.band-fill {
  flex: 1 0 auto;
}

.band-tall h1 {
  font-size: clamp(44px, 7vw, 80px);
  line-height: 1.15;
}

.band-tall > :not(.clover) {
  max-width: 620px;
}

.band-tall .clover, .band-tall:has(+ .card) .clover {
  top: 50%;
  right: max(24px, calc(var(--edge) - 40px));
  width: min(36vw, 440px);
  transform: translateY(-50%);
}

@media (max-width: 1099.98px) {
  .band-tall .clover, .band-tall:has(+ .card) .clover {
    top: 16px;
    right: var(--gutter);
    width: 84px;
    transform: none;
  }

  .band-tall h1 {
    max-width: none;
  }
}

.band-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.band-note {
  font-size: 15px;
}

.lead {
  font-size: 18px;
  line-height: 1.6;
  text-wrap: pretty;
}

/* 控件：高度、圓角、描邊同一套邏輯 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--ctl-h);
  padding: 0 18px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--r-ctl);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease, transform 80ms ease;
}

.btn:hover {
  color: var(--text);
}

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

.btn[disabled] {
  cursor: progress;
  opacity: 0.8;
}

.btn-lg {
  min-height: 52px;
  padding: 0 26px;
  font-size: 17px;
}

.btn-primary {
  font-weight: 700;
  color: var(--ink);
  background: var(--sun);
}

.btn-primary:hover {
  color: var(--ink);
  background: #FFD76B;
}

.btn-outline {
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.btn-outline:hover {
  background: var(--tint);
}

.btn-quiet {
  padding: 0 10px;
}

.btn-quiet:hover {
  background: var(--tint);
}

.band .btn-outline {
  color: var(--white);
  background: transparent;
  box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 0.75);
}

.band .btn-outline:hover {
  color: var(--white);
  background: rgb(12 59 41 / 0.32);
}

.btn-danger, .btn-danger:hover {
  font-weight: 700;
  color: var(--ink);
  background: var(--coral);
}

/* 色塊上的主要按鈕變深綠，次要按鈕變白 */
.chip-sun .btn-primary, .chip-sky .btn-primary, .chip-coral .btn-primary, .chip-mint .btn-primary {
  color: var(--white);
  background: var(--ink);
}

.chip-sun .btn-outline, .chip-sky .btn-outline, .chip-coral .btn-outline, .chip-mint .btn-outline {
  color: var(--ink);
  background: var(--white);
  box-shadow: none;
}

/* 複製鈕：文字換成「已複製」時寬度不變，圖示同時換成打勾 */
[data-copy] {
  min-width: 88px;
}

.btn-copy::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: var(--i-copy) center / contain no-repeat;
  mask: var(--i-copy) center / contain no-repeat;
}

.btn-copy.is-copied::before {
  -webkit-mask-image: var(--i-check);
  mask-image: var(--i-check);
}

.btn-quiet.is-copied, .btn-quiet.is-copied:hover {
  color: var(--accent);
}

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--ctl-h);
  font-size: 15px;
  font-weight: 500;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-size: 15px;
  font-weight: 500;
}

.field input, .field textarea, .search input {
  width: 100%;
  min-width: 0;
  min-height: var(--ctl-h);
  padding: 0 14px;
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-ctl);
}

.field textarea {
  padding: 10px 14px;
  line-height: 1.5;
}

.band .field input, .band .field textarea {
  border-color: transparent;
}

.band .field input:focus-visible, .band .field textarea:focus-visible {
  outline-color: var(--sun);
  outline-offset: 0;
}

[aria-invalid="true"], .band .field [aria-invalid="true"] {
  border-color: var(--error);
}

.hint {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}

.card .hint, .paper .hint {
  color: var(--muted);
}

.form-label {
  font-size: 15px;
  font-weight: 500;
}

/* 搜尋框 */
.search {
  position: relative;
  flex: 0 1 320px;
  min-width: 0;
  margin: 0;
}

.search::before {
  content: "";
  position: absolute;
  top: 13px;
  left: 13px;
  width: 18px;
  height: 18px;
  background: var(--muted);
  -webkit-mask: var(--i-search) center / contain no-repeat;
  mask: var(--i-search) center / contain no-repeat;
  pointer-events: none;
}

.search input {
  padding-left: 40px;
}

/* 貼網址的長條：外框只有一層，對焦時整條亮起來 */
.pill {
  --focus: transparent;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  color: var(--text);
  background: var(--surface);
  border-radius: 18px;
  transition: box-shadow 120ms ease;
}

.pill:focus-within {
  box-shadow: 0 0 0 3px var(--ring, var(--ink));
}

.pill input {
  flex: 999 1 220px;
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  font-size: 18px;
  color: inherit;
  background: transparent;
  border: 0;
  outline: none;
}

.pill .btn {
  --focus: var(--ink);
  flex: 1 0 auto;
  min-height: 52px;
  padding: 0 24px;
  font-size: 17px;
}

.pill-sm input, .pill-sm .btn {
  height: var(--ctl-h);
  min-height: var(--ctl-h);
  font-size: 16px;
}

.chip {
  display: inline-block;
  padding: 1px 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
  border-radius: 999px;
}

/* 四色底，可以加在 .chip、.tag-filter、.card 上。色塊上的東西一律深綠，不隨主題改變 */
.chip-sun, .chip-sky, .chip-coral, .chip-mint {
  --text: var(--ink);
  --muted: var(--ink);
  --surface: var(--white);
  --focus: var(--ink);
  --link-hover: var(--ink);
  color: var(--ink);
}

.chip-sun {
  background: var(--sun);
}

.chip-sky {
  background: var(--sky);
}

.chip-coral {
  background: var(--coral);
}

.chip-mint {
  background: var(--mint);
}

.chip-none {
  color: var(--muted);
  background: var(--tint);
}

.code {
  font-family: var(--font-display);
  font-weight: 400;
}

.code-xl {
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.flash {
  padding: 10px 16px;
  font-weight: 500;
  color: var(--ink);
  background: var(--sky);
  border-radius: var(--r-ctl);
}

.flash-error {
  background: var(--coral);
}

.flash-success {
  background: var(--mint);
}

/* 分段切換：排序、統計範圍 */
.segmented {
  display: inline-flex;
  background: var(--grid);
  border-radius: var(--r-ctl);
}

/* 透明邊框讓選中的白底內縮 3px，觸控區仍是 44px */
.segmented a {
  display: inline-flex;
  align-items: center;
  min-height: var(--ctl-h);
  padding: 0 14px;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: var(--r-ctl);
}

.segmented a:hover {
  color: var(--text);
}

.segmented a[aria-current="true"] {
  color: var(--text);
  background-color: var(--surface);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-filter {
  display: inline-flex;
  align-items: center;
  min-height: var(--ctl-h);
  padding: 0 14px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px var(--rule);
}

.tag-filter[class*="chip-"] {
  box-shadow: none;
}

.tag-filter[aria-current="true"] {
  box-shadow: 0 0 0 2px var(--text);
}

/* 卡片 */

.card {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px 32px;
  padding: clamp(20px, 2.6vw, 28px);
  color: var(--text);
  background: var(--surface);
  border-radius: var(--r-card);
}

.card.chip-sun { background: var(--sun); }
.card.chip-sky { background: var(--sky); }
.card.chip-coral { background: var(--coral); }
.card.chip-mint { background: var(--mint); }

.band + .card {
  margin: -60px var(--edge) 0;
}

.card-narrow {
  max-width: 640px;
}

.card-body {
  flex: 999 1 340px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 8px;
}

.card-kicker {
  font-size: 15px;
  font-weight: 500;
}

.card-title {
  overflow-wrap: anywhere;
}

.card-extra {
  flex: 1 0 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 520px;
}

.qr-box {
  flex: none;
  padding: 8px;
  line-height: 0;
  background: var(--white);
  border-radius: 16px;
}

.qr-box canvas, .qr-box svg {
  max-width: 100%;
  height: auto;
}

/* QR 選項固定用亮色，放在綠色色塊和深色模式裡都看得清楚 */
.qr-panel {
  --text: var(--ink);
  --surface: var(--white);
  --line: #6F8E7F;
  --tint: #EAF2E5;
  --focus: var(--ink);
  color-scheme: light;
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
  padding: 12px 16px;
  color: var(--ink);
  background: var(--white);
  border-radius: var(--r-ctl);
}

.qr-panel[hidden] {
  display: none;
}

.qr-panel .btn-primary {
  color: var(--ink);
  background: var(--sun);
}

.qr-panel .btn-outline, .qr-panel .btn-outline:hover {
  color: var(--ink);
  background: var(--white);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.qr-colors {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.qr-label {
  font-weight: 500;
}

.swatch {
  --sw-fg: var(--ink);
  --sw-bg: var(--white);
  position: relative;
  display: inline-block;
  width: 44px;
  height: 44px;
  cursor: pointer;
}

.swatch[data-fg="green"] { --sw-fg: var(--green); }
.swatch[data-bg="sun"] { --sw-bg: var(--sun); }
.swatch[data-bg="sky"] { --sw-bg: var(--sky); }
.swatch[data-bg="mint"] { --sw-bg: var(--mint); }

.swatch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.swatch-chip {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: var(--sw-bg);
  border: 1.5px solid var(--line);
  border-radius: 50%;
}

.swatch-chip::after {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--sw-fg);
  border-radius: 4px;
}

.swatch input:checked + .swatch-chip {
  box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--ink);
}

.swatch input:focus-visible + .swatch-chip {
  outline: 3px solid var(--focus);
  outline-offset: 6px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--ctl-h);
  font-weight: 500;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--green);
}

.qr-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

@media (min-width: 560px) {
  .qr-downloads {
    margin-left: auto;
  }
}

/* 工作台 */

.shorten {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.adv summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--ctl-h);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.adv summary::-webkit-details-marker {
  display: none;
}

.adv summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 120ms ease;
}

.adv[open] summary::before {
  transform: rotate(45deg);
}

.adv[open] > :not(summary) {
  animation: reveal 160ms ease-out;
}

.adv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  padding-top: 4px;
}

.adv-wide {
  grid-column: 1 / -1;
}

.adv-text {
  max-width: 64ch;
}

@media (max-width: 559.98px) {
  .adv-grid {
    grid-template-columns: 1fr;
  }
}

.recent {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px var(--edge) 56px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
}

.section-head h2 {
  margin-right: auto;
}

@media (max-width: 559.98px) {
  .section-head .search {
    flex: 1 0 100%;
    order: 3;
  }
}

/* 淡綠紙：方格只留在頁面最上方，往下淡掉，列表的字下面沒有格線 */

.paper {
  position: relative;
  flex: 1 0 auto;
  background: var(--paper);
}

.paper::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 180px;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: linear-gradient(#000, transparent);
  mask-image: linear-gradient(#000, transparent);
  pointer-events: none;
}

.page {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px var(--edge) 56px;
}

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

.page-head-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
}

.page-title {
  font-size: clamp(28px, 3.4vw, 36px);
}

.page-count {
  font-size: 15px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.toolbar-end {
  margin-left: auto;
}

@media (max-width: 559.98px) {
  .page-head .search {
    flex: 1 0 100%;
  }
}

/* 一條短網址的列 */

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

.entry-month {
  margin: 20px 0 2px;
  font-family: var(--font-note);
  font-size: 19px;
  font-weight: 700;
}

.entry-month:first-child {
  margin-top: 4px;
}

.entry {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto 72px 96px;
  align-items: center;
  position: relative;
  column-gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
}

/* hover 的底色往兩邊多出一點，線和字仍對齊版心 */
.entry:hover {
  background: var(--tint);
  box-shadow: -10px 0 0 var(--tint), 10px 0 0 var(--tint);
}

.entry-wide {
  grid-template-columns: 84px minmax(0, 1fr) auto 72px 96px;
}

.entry-main {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.entry-title {
  overflow: hidden;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 整列都能點，連到單筆頁；複製鈕疊在上面 */
.entry-title::after {
  content: "";
  position: absolute;
  inset: 0;
}

.entry:hover .entry-title {
  text-decoration: underline;
}

.entry-title-url {
  font-weight: 400;
  color: var(--muted);
}

.entry-disabled .entry-title {
  color: var(--muted);
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.entry-meta .code {
  font-size: 15px;
  color: var(--accent);
}

.entry-info {
  display: contents;
}

.entry-date {
  grid-column: 1;
  grid-row: 1;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.entry-tags {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: 240px;
}

.entry-clicks {
  grid-column: 4;
  grid-row: 1;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  text-align: right;
}

.entry .btn-copy {
  position: relative;
  z-index: 1;
  grid-column: 5;
  grid-row: 1;
  justify-self: end;
}

@media (max-width: 759.98px) {
  .entry, .entry-wide {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
    padding: 10px 0;
  }

  .entry:hover {
    background: none;
    box-shadow: none;
  }

  .entry-main {
    grid-column: 1;
    grid-row: 1;
  }

  .entry-title {
    display: -webkit-box;
    white-space: normal;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .entry-info {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 10px;
  }

  .entry-tags {
    justify-content: flex-start;
    max-width: none;
  }

  .entry .btn-copy {
    grid-column: 2;
    grid-row: 1 / span 2;
    min-width: 76px;
    padding: 0 8px;
  }
}

.list-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 24px 0;
  color: var(--muted);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  margin-top: 8px;
}

.pager-now {
  font-size: 15px;
  color: var(--muted);
}

.pager-off {
  color: var(--muted);
  cursor: default;
  opacity: 0.55;
}

.pager-off:hover {
  background: var(--surface);
}

/* 單筆頁 */

.band-link {
  gap: 4px;
  padding-block: 8px 28px;
}

.band-link > :not(.clover) {
  max-width: none;
}

.back-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: var(--ctl-h);
  font-size: 15px;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px 40px;
}

.hero-main {
  flex: 999 1 420px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-status {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.hero-title {
  font-size: 18px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.hero-dest {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-meta {
  font-size: 14px;
}

.band-link .qr-panel {
  margin-top: 16px;
}

.hero-jump {
  display: none;
}

@media (max-width: 559.98px) {
  .hero .qr-box {
    display: none;
  }

  .hero:has(+ .qr-panel:not([hidden])) .qr-box {
    display: block;
  }
}

.detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  align-items: start;
  gap: 32px 40px;
}

.detail-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

@media (max-width: 1039.98px) {
  .detail {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-jump {
    display: inline-flex;
  }
}

.stats, .history {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-note {
  font-family: var(--font-note);
  font-size: 15px;
  line-height: 1.7;
  color: var(--muted);
}

.tally {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 20px;
  margin: 0;
}

.tally dt {
  font-size: 14px;
  color: var(--muted);
}

.tally dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(30px, 4vw, 40px);
  line-height: 1.2;
}

.trend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.trend figcaption {
  font-family: var(--font-note);
  font-size: 17px;
  font-weight: 700;
}

.trend-svg {
  display: block;
  width: 100%;
  height: 120px;
  overflow: visible;
}

.trend-bar {
  fill: var(--bar);
}

.trend-base {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.trend-axis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.trend-alt {
  font-size: 15px;
}

.trend-table summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--ctl-h);
  font-size: 15px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.trend-table table {
  width: 100%;
  max-width: 360px;
  border-collapse: collapse;
  font-size: 15px;
}

.trend-table th, .trend-table td {
  padding: 6px 0;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}

.trend-table th[scope="row"] {
  font-weight: 400;
}

.trend-table td {
  text-align: right;
}

.ranks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px 28px;
}

.rank h3 {
  margin-bottom: 8px;
  font-family: var(--font-note);
  font-size: 17px;
  font-weight: 700;
}

.rank ol {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  font-size: 15px;
}

.rank-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rank-n {
  font-variant-numeric: tabular-nums;
}

.rank-bar {
  grid-column: 1 / -1;
  display: block;
  width: var(--w);
  height: 4px;
  background: var(--bar);
  border-radius: 2px;
}

.rank-empty, .history-empty {
  font-size: 15px;
  color: var(--muted);
}

.edit-card {
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  box-shadow: inset 0 0 0 1px var(--rule);
}

.edit-head h2 {
  margin-bottom: 2px;
  scroll-margin-top: 16px;
}

.edit-form, .edit-more {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.edit-more {
  padding-top: 4px;
}

.edit-form .adv {
  margin-block: -6px;
}

.edit-danger {
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}

.edit-danger p {
  margin-bottom: 12px;
}

.danger summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--ctl-h);
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.danger-body {
  margin-top: 8px;
  padding: 14px 16px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1.5px var(--coral);
  border-radius: var(--r-ctl);
}

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

.change {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}

.change-when {
  font-family: var(--font-note);
  font-size: 14px;
  color: var(--muted);
}

.change-what, .change-diff {
  overflow-wrap: anywhere;
}

.change-diff {
  font-size: 15px;
}

.change-diff del {
  color: var(--muted);
}

.change-diff ins {
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--sun);
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
}

@media (max-width: 559.98px) {
  .tally {
    gap: 8px 12px;
  }
}

/* 批次建立 */

.batch-form {
  gap: 12px;
  padding-bottom: 16px;
}

.band textarea {
  min-height: 132px;
}

.file-pick {
  cursor: pointer;
}

.file-pick:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.csv-help {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 760px;
}

.csv-help table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.csv-help th, .csv-help td {
  padding: 8px 12px 8px 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
  overflow-wrap: anywhere;
}

.csv-help th {
  font-weight: 500;
  white-space: nowrap;
}

.batch-card {
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  box-shadow: inset 0 0 0 1px var(--rule);
}

.batch-card .card-actions {
  margin-top: 4px;
}

.batch-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

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

.batch-row {
  display: grid;
  grid-template-columns: 5em auto 1fr;
  align-items: baseline;
  gap: 4px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
}

.batch-row .chip {
  justify-self: start;
}

.batch-line {
  font-size: 14px;
  color: var(--muted);
}

.batch-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.batch-main .code {
  color: var(--accent);
}

.batch-url, .batch-msg {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.batch-row[data-result="failed"] .batch-msg {
  font-weight: 500;
}

@media (max-width: 559.98px) {
  .batch-row {
    grid-template-columns: auto auto;
    justify-content: start;
  }

  .batch-main {
    grid-column: 1 / -1;
  }
}

/* 動畫：建立成功時標誌彈出來，結果卡跟著升上來。用獨立的 scale，不動 .clover 定位用的 transform */

@keyframes bloom {
  from {
    opacity: 0;
    scale: 0.6;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.band-bloom .clover {
  animation: bloom 460ms cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
}

.band-bloom + .card {
  animation: rise 280ms ease-out 120ms backwards;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }

  .btn:active {
    transform: none;
  }
}
