:root {
  --bg: #f7f4ee;
  --paper: #fffdf8;
  --soft: #fbf4e7;
  --ink: #1f1b16;
  --muted: #746b5f;
  --line: rgba(116, 97, 64, .18);
  --line-strong: rgba(169, 139, 95, .48);
  --wood: #a98b5f;
  --wood-dark: #755c37;
  --green: #4f724f;
  --green-soft: #eaf3e8;
  --shadow: 0 18px 42px rgba(74, 58, 31, .1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(194, 176, 143, .12) 1px, transparent 1px) 0 0 / 38px 38px,
    linear-gradient(0deg, rgba(194, 176, 143, .1) 1px, transparent 1px) 0 0 / 38px 38px,
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(430px, 100%);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 16px max(34px, env(safe-area-inset-bottom));
}

.client-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--wood-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}

h1 {
  margin: 4px 0 0;
  font-size: 30px;
  line-height: 1.15;
}

.icon-button {
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, .92);
  box-shadow: 0 8px 20px rgba(74, 58, 31, .08);
  font-size: 24px;
  color: var(--ink);
}

.token-panel,
.board,
.message {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 253, 248, .94);
  box-shadow: var(--shadow);
}

.token-panel {
  padding: 22px;
}

.token-panel h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.token-panel p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.7;
}

.token-panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.token-panel input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: #fff;
  color: var(--ink);
}

.token-panel button {
  width: 100%;
  margin-top: 14px;
  border: 0;
  border-radius: 999px;
  padding: 13px 16px;
  background: var(--wood);
  color: #fff;
  font-weight: 800;
}

.board {
  padding: 18px 16px 20px;
}

.board-top {
  padding: 0 4px 16px;
  border-bottom: 1px solid var(--line);
}

.crumb {
  color: var(--wood-dark);
  font-size: 12px;
  line-height: 1.5;
}

.board-top h2 {
  margin: 6px 0 10px;
  font-size: 25px;
  line-height: 1.2;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(67, 116, 72, .25);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.vip-card {
  margin: 16px 0 12px;
  padding: 16px;
  border: 1px solid rgba(169, 139, 95, .28);
  border-radius: 22px;
  background:
    radial-gradient(circle at 80% 15%, rgba(208, 185, 139, .16), transparent 36%),
    linear-gradient(135deg, #fff8eb, #fbfbf5);
}

.vip-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--wood-dark);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.vip-chip {
  display: inline-flex;
  margin-top: 9px;
  border: 1px solid rgba(169, 139, 95, .32);
  border-radius: 999px;
  padding: 5px 10px;
  background: #fffdf8;
  color: var(--wood-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
}

.vip-card h3 {
  margin: 12px 0 6px;
  font-size: 23px;
}

.vip-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.vip-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.vip-stats span {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 253, 248, .72);
  padding: 9px 10px;
  color: var(--muted);
  font-size: 12px;
}

.vip-stats strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.1;
}

.stage-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  width: min(330px, 100%);
  margin: 10px auto 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 8px 10px;
  background: rgba(255, 253, 248, .86);
}

.stage-tabs span {
  position: relative;
  display: grid;
  place-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stage-tabs span::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: rgba(169, 139, 95, .16);
  box-shadow: inset 0 0 0 3px rgba(255, 253, 248, .82);
}

.stage-tabs span.active {
  color: var(--ink);
}

.stage-tabs span.active::before,
.stage-tabs span.done::before {
  background: var(--wood);
}

.latest-update-card {
  display: grid;
  gap: 8px;
  margin: 14px 0 12px;
  padding: 13px 14px;
  border: 1px solid rgba(169, 139, 95, .28);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff8eb, #fffdf8);
}

.latest-update-card.alert {
  border-color: rgba(173, 64, 55, .36);
  background: linear-gradient(180deg, #fff1ec, #fffdf8);
}

.latest-update-card.ok {
  border-color: rgba(67, 116, 72, .28);
  background: linear-gradient(180deg, #edf7ea, #fffdf8);
}

.latest-update-card div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.latest-update-card span {
  color: var(--wood-dark);
  font-size: 12px;
  font-weight: 900;
}

.latest-update-card.alert span,
.latest-update-card.alert strong {
  color: #9a3c34;
}

.latest-update-card.ok span,
.latest-update-card.ok strong {
  color: var(--green);
}

.latest-update-card strong {
  color: var(--ink);
  font-size: 15px;
}

.latest-update-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.board-section {
  margin-top: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 8px;
  color: var(--wood-dark);
  font-size: 14px;
}

.section-title.done {
  color: var(--green);
}

#pendingLabel {
  color: #9a3c34;
  font-weight: 900;
}

#pendingNote {
  border-color: rgba(173, 64, 55, .28);
  background: #fff1ec;
  color: #8b3931;
}

.section-toggle {
  border: 1px solid rgba(67, 116, 72, .24);
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 900;
}

.section-note,
.completed-box {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--soft);
  padding: 12px 14px;
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.6;
}

.completed-box {
  color: var(--ink);
  font-weight: 800;
}

.card-list {
  display: grid;
  gap: 10px;
}

.notice-card,
.read-card {
  border: 1px solid var(--line-strong);
  border-left-width: 5px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff9ee, #fffdf8);
  padding: 14px;
}

.notice-card.done {
  border-color: rgba(80, 114, 79, .34);
  border-left-color: var(--green);
  background: linear-gradient(180deg, #f5fbf2, #fffdf8);
}

#pendingList .notice-card {
  border-color: rgba(173, 64, 55, .38);
  border-left-color: #ad4037;
  background: linear-gradient(180deg, #fff1ec, #fffdf8);
}

.notice-card h3,
.read-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.notice-card p,
.read-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.meta-row span,
.read-card small {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(255, 253, 248, .78);
  color: var(--muted);
  font-size: 12px;
}

.card-action {
  display: inline-flex;
  margin-top: 10px;
  border: 1px solid rgba(67, 116, 72, .32);
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

#pendingList .card-action {
  border-color: rgba(173, 64, 55, .34);
  background: #fff1ec;
  color: #9a3c34;
}

.confirm-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  margin-top: 12px;
  border: 1px solid rgba(169, 139, 95, .42);
  border-radius: 999px;
  background: #fff7e8;
  color: var(--wood-dark);
  font-weight: 900;
  cursor: pointer;
}

.confirm-button:disabled {
  cursor: default;
  opacity: .82;
}

.confirm-button.sent {
  border-color: rgba(67, 116, 72, .35);
  background: var(--green-soft);
  color: var(--green);
}

.read-grid {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.read-card {
  border-left-width: 1px;
}

.public-gantt-card {
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff9ee, #fffdf8);
  padding: 14px;
  min-width: 0;
  overflow: hidden;
}

.public-gantt-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.public-gantt-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.public-gantt-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.public-gantt-head > span {
  border: 1px solid rgba(169, 139, 95, .28);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 253, 248, .85);
  color: var(--wood-dark);
  font-size: 12px;
  font-weight: 900;
}

.public-gantt-pager {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.public-gantt-pager button {
  border: 1px solid rgba(169, 139, 95, .32);
  border-radius: 999px;
  background: rgba(255, 253, 248, .9);
  color: var(--wood-dark);
  padding: 8px 13px;
  font-weight: 900;
}

.public-gantt-pager button:disabled {
  color: rgba(116, 107, 95, .42);
  background: rgba(255, 253, 248, .45);
}

.public-gantt-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 5px;
}

.public-gantt-month {
  --cell: 24px;
  min-width: calc(96px + (var(--days) * var(--cell)));
  display: grid;
  gap: 0;
}

.public-gantt-month-line,
.public-gantt-day-row,
.public-gantt-task-row {
  display: grid;
  grid-template-columns: 96px repeat(var(--days), var(--cell));
}

.public-gantt-month-line {
  min-height: 31px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 247, 232, .68);
}

.public-gantt-month-line strong,
.public-gantt-day-row strong,
.public-gantt-task-row > strong {
  position: sticky;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  background: rgba(255, 253, 248, .96);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  padding-right: 8px;
}

.public-gantt-month-line span {
  grid-column: 2 / -1;
  display: grid;
  place-items: center;
  color: var(--wood-dark);
  font-size: 12px;
  font-weight: 900;
}

.public-gantt-day-row {
  min-height: 42px;
  border-bottom: 1px solid var(--line);
}

.public-gantt-day {
  display: grid;
  place-items: center;
  gap: 2px;
  border-left: 1px solid rgba(169, 139, 95, .14);
  color: var(--muted);
  font-size: 10px;
}

.public-gantt-day b {
  font-size: 11px;
}

.public-gantt-day small {
  font-size: 10px;
}

.public-gantt-day.weekend,
.public-gantt-month-track::before {
  background: rgba(196, 189, 177, .28);
}

.public-gantt-task-row {
  min-height: 43px;
  border-bottom: 1px solid rgba(169, 139, 95, .12);
}

.public-gantt-task-row > strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-gantt-month-track {
  position: relative;
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: repeat(var(--days), var(--cell));
  align-items: center;
  background: repeating-linear-gradient(90deg, transparent 0 calc(var(--cell) - 1px), rgba(169, 139, 95, .14) calc(var(--cell) - 1px) var(--cell));
}

.public-gantt-month-bar {
  display: block;
  min-width: 16px;
  height: 21px;
  border-radius: 999px;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 21px;
  overflow: hidden;
  padding: 0 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-gantt-month-bar.gold { background: #c4a54c; }
.public-gantt-month-bar.green { background: #6f9f59; }
.public-gantt-month-bar.blue { background: #5f83c8; }
.public-gantt-month-bar.rust { background: #c97a55; }
.public-gantt-month-bar.olive { background: #9d9a46; }
.public-gantt-month-bar.pink { background: #c157ad; }

.public-gantt-empty {
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  margin-top: 10px;
  padding: 14px;
  color: var(--muted);
}

.read-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.read-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(80, 114, 79, .2);
  border-radius: 10px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
}

.update-line {
  margin: 16px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.message {
  margin-top: 14px;
  padding: 14px 16px;
  color: var(--muted);
  line-height: 1.6;
}

.message.error {
  border-color: rgba(163, 58, 51, .28);
  background: #fff4f1;
  color: #95342e;
}

[hidden] { display: none !important; }

@media (max-width: 360px) {
  .app-shell { padding-left: 10px; padding-right: 10px; }
  h1 { font-size: 27px; }
  .board { padding-left: 12px; padding-right: 12px; }
}
