:root {
  --paper: #f7f3eb;
  --panel: #fffaf1;
  --ink: #25221e;
  --muted: #71685d;
  --line: #ded4c3;
  --green: #315f53;
  --green-dark: #174a3b;
  --green-soft: #dce9e1;
  --amber: #a7682a;
  --amber-soft: #f1dfc2;
  --gray-soft: #ebe6dc;
  --shadow: 0 18px 44px rgba(46, 38, 27, 0.13);
  --radius: 8px;
  --body-font: "Avenir Next", "PingFang TC", "Noto Sans TC", sans-serif;
  --display-font: Georgia, "Times New Roman", "Noto Serif TC", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(49, 95, 83, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(49, 95, 83, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: var(--body-font);
  letter-spacing: 0;
}

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

[hidden] {
  display: none !important;
}

button {
  cursor: pointer;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
  color: var(--ink);
  padding: 0 12px;
}

textarea {
  min-height: 116px;
  padding: 10px 12px;
  line-height: 1.45;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(49, 95, 83, 0.22);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 0;
}

.sidebar,
.detail-panel {
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.92);
  box-shadow: var(--shadow);
}

.sidebar {
  min-width: 0;
  border-right: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.detail-panel {
  min-width: 0;
  overflow: hidden;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.brand-tools {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.brand-mark,
.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: var(--display-font);
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

.sync-pill {
  border: 1px solid rgba(49, 95, 83, 0.24);
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  padding: 6px 9px;
  white-space: nowrap;
}

.sync-pill.is-error {
  background: var(--amber-soft);
  color: var(--amber);
}

.sync-pill.is-saving {
  background: #e7eef9;
  color: #315a86;
}

.search-block {
  display: grid;
  gap: 10px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.66);
  padding: 10px;
}

.stat strong {
  display: block;
  font-family: var(--display-font);
  font-size: 21px;
  line-height: 1;
}

.stat span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.site-list {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.site-card {
  width: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.78);
  color: inherit;
  padding: 12px;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
  overflow: hidden;
}

.site-card:hover,
.site-card.is-active {
  transform: translateY(-1px);
  border-color: rgba(49, 95, 83, 0.55);
  background: #fffdf8;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.card-title {
  font-weight: 900;
  line-height: 1.28;
}

.card-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status.is-live {
  color: var(--green-dark);
  background: var(--green-soft);
}

.status.is-paused {
  color: var(--amber);
  background: var(--amber-soft);
}

.status.is-done {
  color: #625d55;
  background: var(--gray-soft);
}

.status.is-unknown {
  color: #4f5961;
  background: #e2e8ec;
}

.empty-state {
  display: none;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.6);
  color: var(--muted);
  font-weight: 800;
  padding: 18px;
  text-align: center;
}

.detail-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(49, 95, 83, 0.09), transparent 46%),
    #fffdf8;
  padding: 22px;
}

.detail-hero > div:first-child {
  min-width: 0;
}

.detail-hero h2 {
  font-size: clamp(30px, 4vw, 42px);
  overflow-wrap: anywhere;
}

.detail-hero p:not(.eyebrow) {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.command {
  min-height: 40px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf1;
  color: var(--ink);
  font-weight: 800;
  padding: 0 12px;
  white-space: nowrap;
}

.command.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #fffaf1;
}

.create-site-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
}

.info-card {
  min-width: 0;
  min-height: 86px;
  border: 1px solid rgba(222, 212, 195, 0.82);
  border-radius: var(--radius);
  background: rgba(247, 243, 235, 0.42);
  padding: 13px;
}

.info-card > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.info-card strong {
  display: block;
  font-size: 17px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.password-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.password {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
}

.mini-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  padding: 0 9px;
}

.notes-block {
  padding: 0 18px 18px;
}

.notes-block h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.notes-block ul {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.notes-block li {
  border-left: 3px solid var(--green);
  border-radius: 0 7px 7px 0;
  background: rgba(49, 95, 83, 0.06);
  line-height: 1.45;
  padding: 10px 12px;
}

.edit-form {
  padding: 18px;
}

.edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.edit-notes {
  grid-column: 1 / -1;
}

.toggle-line {
  min-height: 42px;
  display: flex;
  align-items: center;
  align-self: end;
  gap: 9px;
  border: 1px solid rgba(222, 212, 195, 0.82);
  border-radius: var(--radius);
  background: rgba(247, 243, 235, 0.42);
  padding: 0 12px;
}

.toggle-line input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

.toggle-line span {
  color: var(--ink);
  font-size: 14px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 20;
  transform: translateX(-50%) translateY(18px);
  border-radius: 999px;
  background: var(--ink);
  color: #fffaf1;
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .sidebar,
  .detail-panel {
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .sidebar {
    border-bottom: 0;
    padding: 16px;
  }

  .site-list {
    display: flex;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .site-card {
    flex: 0 0 min(78vw, 310px);
    min-width: 0;
    scroll-snap-align: start;
  }

  .detail-hero {
    display: grid;
    padding: 18px 16px;
  }

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 25px;
  }

  .filter-grid,
  .info-grid,
  .edit-grid {
    grid-template-columns: 1fr;
  }

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

  .actions .command {
    flex: 1 1 auto;
  }

  .info-grid,
  .notes-block,
  .edit-form {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* ===== Open Design 視覺升級：更有層次、留白與微互動 ===== */
:root {
  --open-font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Noto Sans", sans-serif;
  --open-ink: #121b18;
  --open-ink-soft: #48544f;
  --open-bg-a: #f4f8f3;
  --open-bg-b: #eff4ff;
  --open-line: rgba(20, 31, 26, 0.09);
  --open-card: rgba(255, 255, 255, 0.92);
  --open-accent: #275e54;
  --open-accent-2: #3b8e73;
  --open-warn: #c27f1f;
  --open-shadow: 0 20px 50px rgba(21, 30, 21, 0.14);
}

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

body {
  position: relative;
  font-family: var(--open-font);
  color: var(--open-ink);
  background:
    radial-gradient(1180px 520px at 96% -10%, rgba(59, 142, 115, 0.18), transparent 55%),
    radial-gradient(980px 420px at -8% 16%, rgba(70, 100, 145, 0.12), transparent 50%),
    linear-gradient(160deg, var(--open-bg-a), var(--open-bg-b));
  line-height: 1.45;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 220px at 100% 0%, rgba(255, 255, 255, 0.25), transparent 60%),
    radial-gradient(700px 260px at 0% 98%, rgba(59, 142, 115, 0.08), transparent 62%);
  z-index: -1;
}

.app-shell,
.sidebar,
.detail-panel {
  animation: od-fade-up 0.52s ease-out;
}

.sidebar,
.detail-panel,
.stat,
.site-card,
.info-card,
.notes-block li,
.password {
  border-radius: 14px;
  border-color: var(--open-line);
}

.sidebar,
.detail-panel {
  border-width: 1px;
  background: var(--open-card);
  box-shadow: var(--open-shadow);
}

.brand-mark,
.eyebrow {
  color: var(--open-accent);
}

h1,
h2 {
  letter-spacing: 0.01em;
}

.detail-hero {
  background:
    linear-gradient(140deg, rgba(59, 142, 115, 0.12), transparent 46%),
    #f9fdfb;
  border-bottom-color: rgba(23, 43, 34, 0.12);
}

.sync-pill,
.status.is-live,
.status.is-paused,
.status.is-done,
.status.is-unknown {
  border-radius: 999px;
}

.sync-pill {
  border: 1px solid rgba(23, 43, 34, 0.12);
  background: rgba(59, 142, 115, 0.15);
  color: #1d423a;
}

.sync-pill.is-error {
  color: #8d311f;
  background: rgba(183, 72, 45, 0.16);
}

.sync-pill.is-saving {
  color: #244e7c;
  background: rgba(75, 120, 166, 0.16);
}

.brand-tools .command {
  box-shadow: none;
}

button,
.command,
.command.primary,
.mini-button,
.site-card,
.stat,
.edit-form,
.detail-panel .info-card {
  transition: transform 190ms ease, border-color 190ms ease, box-shadow 190ms ease, background 190ms ease;
}

button:hover,
.command:hover,
.mini-button:hover,
.site-card:hover,
.stat:hover,
.info-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(21, 30, 21, 0.12);
}

.command.primary {
  background: linear-gradient(135deg, #275e54, #3b8e73);
  color: #fffaf0;
  border-color: #24453d;
}

.command {
  background: #fff;
  min-height: 40px;
  border-radius: 12px;
}

.mini-button {
  background: #fff;
  border-radius: 10px;
}

.search-block,
.notes-block,
.edit-form,
.brand-row,
.detail-hero,
.sidebar,
.detail-panel,
.site-card,
.stats,
.info-grid {
  animation: od-fade-up 0.45s ease-out both;
}

.site-list .site-card {
  animation-delay: 0.04s;
}

.site-list .site-card:nth-child(1) {
  animation-delay: 0.04s;
}

.site-list .site-card:nth-child(2) {
  animation-delay: 0.08s;
}

.site-list .site-card:nth-child(3) {
  animation-delay: 0.12s;
}

.site-list .site-card:nth-child(4) {
  animation-delay: 0.16s;
}

.card-title,
.stat strong,
.info-card strong,
.password,
h2#detailTitle,
#detailTitle {
  color: #133127;
}

.notes-block li {
  background: rgba(39, 94, 84, 0.07);
  border-left-width: 4px;
}

.notes-block h3,
.search-block label span,
.edit-form label span {
  color: var(--open-ink-soft);
}

.edit-form input,
.edit-form select,
.edit-form textarea,
.toggle-line {
  background: rgba(255, 255, 255, 0.88);
  border-color: var(--open-line);
  border-radius: 12px;
}

.toast {
  border-radius: 999px;
  backdrop-filter: blur(8px);
  background: rgba(16, 27, 24, 0.88);
}

@keyframes od-fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 880px) {
  .app-shell {
    padding-top: 8px;
    padding-bottom: 14px;
  }

  .sidebar,
  .detail-panel {
    border-radius: 16px 16px 0 0;
  }

  .site-list {
    padding-bottom: 10px;
  }
}

@media (max-width: 560px) {
  .brand-row,
  .brand-tools,
  .detail-hero,
  .actions {
    display: grid;
    align-items: stretch;
    gap: 12px;
  }

  .brand-tools .command {
    width: 100%;
  }

  .actions .command {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell,
  .sidebar,
  .detail-panel,
  .site-card,
  .search-block,
  .notes-block,
  .detail-hero,
  .stats,
  .info-grid,
  button,
  .command,
  .mini-button,
  .site-list .site-card,
  .toast {
    animation: none;
    transition: none;
  }
}
