:root {
  --bg: #f4f7f7;
  --panel: #ffffff;
  --line: #dce4e7;
  --text: #1c2a2f;
  --muted: #64747a;
  --teal: #ee4d2d;
  --teal-soft: #fff1ec;
  --orange: #e95f2a;
  --orange-soft: #fff0e8;
  --green: #2d7d46;
  --green-soft: #eaf5ed;
  --amber: #a46a12;
  --amber-soft: #fff6df;
  --blue: #2f6f9f;
  --blue-soft: #e8f1f8;
  --shadow: 0 14px 32px rgba(28, 42, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", Arial, sans-serif;
  line-height: 1.45;
}

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

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
}

.sidebar {
  min-height: 100vh;
  padding: 20px 14px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
}

.brand {
  font-size: 20px;
  font-weight: 900;
  margin: 0 8px 18px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
}

.nav a.active {
  color: var(--teal);
  background: var(--teal-soft);
}

.main {
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) 360px;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.stat span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.row,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.name {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
}

.meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.wait { color: var(--amber); background: var(--amber-soft); }
.badge.done { color: var(--green); background: var(--green-soft); }
.badge.edit { color: var(--orange); background: var(--orange-soft); }
.badge.scan { color: var(--blue); background: var(--blue-soft); }

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
}

input,
select,
textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
  font: inherit;
  padding: 0 12px;
}

textarea {
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
}

input[type="file"] {
  padding: 9px 12px;
}

.button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 13px;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.button.approve { background: var(--green); }
.button.remake { background: var(--amber); }
.button.download { background: var(--orange); }
.button.danger { background: #c2410c; }

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

.task-row {
  cursor: pointer;
}

.task-row.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.task-detail {
  margin-top: 12px;
}

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

.video-preview {
  height: 132px;
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #edf3f3;
}

.video-preview svg {
  width: 100%;
  height: 100%;
  display: block;
}

.video-player {
  width: 100%;
  height: 100%;
  display: block;
  background: #111;
  object-fit: contain;
}

.title-line {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
}

.mobile-page {
  min-height: 100vh;
  background: #edf3f1;
}

.mobile-shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 18px 14px 94px;
}

.mobile-header {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 74px;
  padding: 8px 2px 18px;
}

.mobile-kicker {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.mobile-header h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
  white-space: nowrap;
  word-break: keep-all;
}

.mobile-credit {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.member-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.member-summary span,
.member-summary strong {
  display: block;
  min-width: 0;
}

.member-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.member-summary strong {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.member-summary .compact-logout {
  width: auto;
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.credit-overview {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.credit-overview[hidden] {
  display: none;
}

.credit-overview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.credit-overview-header h2,
.credit-overview-header p {
  margin: 0;
}

.credit-overview-header h2 {
  font-size: 18px;
  line-height: 1.15;
}

.credit-overview-header p,
.credit-overview-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.credit-overview-header span {
  white-space: nowrap;
}

.credit-balance-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: #1c2a2f;
  color: #fff;
  box-shadow: var(--shadow);
}

.credit-balance-panel strong {
  display: block;
  margin-top: 8px;
  font-size: 44px;
  line-height: 0.95;
}

.credit-balance-panel p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 900;
}

.credit-label,
.credit-date {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

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

.credit-metric {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.credit-metric strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.credit-metric span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.credit-list-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.credit-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.credit-section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.credit-section-title h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.15;
}

.credit-section-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.credit-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.credit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.credit-row strong,
.credit-row span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.credit-row strong {
  font-size: 13px;
  font-weight: 900;
}

.credit-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.credit-row em {
  color: var(--orange);
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.credit-empty {
  padding: 10px 0 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.install-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid #f3b7a6;
  border-radius: 8px;
  background: #fff7f3;
  box-shadow: var(--shadow);
}

.install-prompt strong,
.install-prompt span {
  display: block;
}

.install-prompt strong {
  font-size: 14px;
  font-weight: 900;
}

.install-prompt span,
.install-note {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.install-button {
  white-space: nowrap;
}

.invite-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--bg);
}

.invite-gate[hidden] {
  display: none;
}

.invite-card {
  width: min(380px, 100%);
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.invite-logo {
  width: 92px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 18px;
}

.invite-card h2,
.invite-card p {
  margin: 0;
}

.invite-card input {
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  font-weight: 800;
}

.mobile-screen {
  display: grid;
  gap: 12px;
}

.mobile-screen[hidden] {
  display: none;
}

.mobile-brand-art {
  width: min(100%, 188px);
  aspect-ratio: 1 / 1;
  justify-self: center;
  object-fit: cover;
  border-radius: 26px;
  box-shadow: 0 14px 30px rgba(238, 77, 45, 0.22);
}

.mobile-section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px;
}

.mobile-section-title.compact {
  margin-top: 6px;
}

.mobile-section-title h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.mobile-section-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.mobile-form {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.mobile-form input,
.mobile-form select,
.mobile-form textarea {
  width: 100%;
  min-height: 52px;
  font-size: 16px;
}

.mobile-form textarea {
  min-height: 112px;
}

.subtitle-color-field {
  display: grid;
  gap: 8px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

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

.subtitle-color-option {
  min-width: 0;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.subtitle-color-option:has(input:checked) {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: inset 0 0 0 1px rgba(238, 77, 45, 0.28);
}

.subtitle-color-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.subtitle-swatch {
  flex: 0 0 30px;
  width: 30px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(238, 77, 45, 0.12) 25%, transparent 25% 50%, rgba(47, 111, 159, 0.12) 50% 75%, transparent 75%),
    #f6f9f9;
  background-size: 10px 10px;
  border: 1px solid rgba(28, 42, 47, 0.26);
}

.subtitle-swatch::before {
  content: "字";
  color: var(--subtitle-text);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  text-shadow: -1px 0 #000, 0 1px #000, 1px 0 #000, 0 -1px #000;
}

.subtitle-swatch.white-outline::before {
  text-shadow: -1px 0 #fff, 0 1px #fff, 1px 0 #fff, 0 -1px #fff;
}

.make-count-control {
  display: grid;
  grid-template-columns: 1fr 74px 74px;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.make-count-control span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.make-count-control button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.make-count-control button.active {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.mobile-page .list,
.mobile-page .video-list {
  display: grid;
  gap: 10px;
  padding: 0;
}

.mobile-page .row,
.mobile-page .card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.mobile-page .name {
  font-size: 16px;
}

.mobile-page .meta {
  font-size: 13px;
  line-height: 1.55;
}

.mobile-page .actions {
  display: grid;
  grid-template-columns: 1fr;
  justify-content: stretch;
}

.mobile-page .button {
  width: 100%;
  min-height: 50px;
  font-size: 15px;
}

.mobile-page .member-summary .compact-logout {
  width: auto;
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.mobile-page .badge {
  min-height: 32px;
  width: fit-content;
}

.mobile-page .video-preview {
  height: auto;
  aspect-ratio: 9 / 16;
  max-height: 68vh;
}

.mobile-page .video-player {
  object-fit: contain;
}

.library-control,
.library-pick-row {
  gap: 14px;
}

.library-count-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
}

.library-hashtags {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 247, 237, 0.85);
}

.library-hashtags.compact {
  margin-top: 8px;
  padding: 8px 10px;
}

.hashtag-text {
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
  color: var(--ink);
}

.library-pick-main {
  min-width: 0;
}

.library-pick-actions {
  display: grid;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 24px rgba(28, 42, 47, 0.12);
}

.mobile-nav button {
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.mobile-nav button.active {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

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

  .sidebar {
    min-height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .main {
    padding: 16px;
  }

  .stats,
  .grid.two,
  .grid.three,
  .video-grid {
    grid-template-columns: 1fr;
  }
}
