/* Life OS — 完全跟隨「到齊」設計系統 */

:root {
  --background: #f2f1ee;
  --foreground: #3c3c39;
  --card: #fbfbfa;
  --popover: #fbfbfa;
  --primary: #56544f;
  --primary-dark: #3f3e3a;
  --primary-foreground: #ffffff;
  --primary-soft: #eceae5;
  --secondary: #eceae5;
  --accent: #eceae5;
  --muted: #ecebe7;
  --muted-foreground: #8d8c86;
  --border: #e5e4e0;
  --input: #e5e4e0;
  --ring: #56544f;
  --destructive: #9c4a44;
  --error-bg: #f2e4e2;
  --success: #6e7a5c;
  --success-bg: #e9ebe2;
  --warning: #9a7a48;
  --warning-bg: #f1ebe0;
  --dark-panel: #3f3e3a;
  --panel-fg: #f2f1ee;
  --panel-muted: #b9b7b1;
  --hover: rgba(60, 60, 57, 0.05);
  --radius: 14px;
  --font: 'Kiwi Maru', Arial, 'PingFang HK', 'Microsoft JhengHei', sans-serif;
}

.dark {
  --background: #1b1a18;
  --foreground: #eceae5;
  --card: #242320;
  --popover: #242320;
  --primary: #c9c6bf;
  --primary-dark: #dedbd4;
  --primary-foreground: #1b1a18;
  --primary-soft: #2e2d2a;
  --secondary: #2e2d2a;
  --accent: #2e2d2a;
  --muted: #2a2926;
  --muted-foreground: #a5a29b;
  --border: #3a3835;
  --input: #3a3835;
  --ring: #c9c6bf;
  --destructive: #d68b83;
  --error-bg: #3a2927;
  --success: #a8b98c;
  --success-bg: #2c3327;
  --warning: #cbaa6d;
  --warning-bg: #322c22;
  --dark-panel: #2b2a27;
  --panel-fg: #eceae5;
  --panel-muted: #a5a29b;
  --hover: rgba(255, 255, 255, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  font-size: 16px;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

button,
input,
textarea,
select {
  font: inherit;
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

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

/* ---------- Topbar ---------- */

.topbar {
  height: 82px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(16px, 5%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 26px;
  font-weight: 800;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 12px;
  width: 38px;
  height: 38px;
  font-size: 18px;
}

.brand-en {
  font-size: 12px;
  letter-spacing: 2px;
  margin-left: 8px;
  color: var(--muted-foreground);
  font-weight: 600;
}

.topnote {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted-foreground);
}

.topbar-icon {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  border-radius: 9px;
  font-size: 17px;
}

.topbar-note {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 9px;
  min-height: 40px;
}

.topbar-icon:hover,
.topbar-note:hover {
  background: var(--muted);
}

.topbar-capture {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 9px;
}

/* ---------- Workspace ---------- */

.workspace {
  max-width: 1320px;
  margin: auto;
  padding: 42px max(16px, 5%) 60px;
}

.heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: 600;
  color: var(--muted-foreground);
  margin-bottom: 12px;
}

.heading h1 {
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -1px;
}

h2 {
  font-size: 18px;
  font-weight: 700;
}

/* ---------- Event strip ---------- */

.event-strip {
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--card);
  padding: 23px 26px;
}

.calendar-icon {
  color: var(--primary);
  background: var(--primary-soft);
  padding: 14px;
  border-radius: 12px;
  font-size: 22px;
  line-height: 1;
}

.event-text {
  flex: 1;
  min-width: 0;
}

.event-text h2 {
  font-size: 22px;
  font-weight: 750;
}

.event-strip p {
  font-size: 14px;
  color: var(--muted-foreground);
  margin-top: 7px;
}

.pill {
  margin-left: auto;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
}

/* ---------- Stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 28px 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 0;
}

.stats > div {
  padding: 0 28px;
  border-right: 1px solid var(--border);
}

.stats > div:last-child {
  border: 0;
}

.stats span {
  font-size: 14px;
  color: var(--muted-foreground);
}

.stats strong {
  display: block;
  font-size: 42px;
  line-height: 1.5;
  letter-spacing: -2px;
  font-weight: 800;
}

.stats small {
  font-size: 14px;
  font-weight: 400;
  color: var(--muted-foreground);
  margin-left: 8px;
  letter-spacing: 0;
}

/* ---------- Content grid ---------- */

.content-grid {
  display: grid;
  grid-template-columns: 440px minmax(0, 1fr);
  gap: 24px;
  margin-bottom: 24px;
  align-items: start;
}

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

.content-side {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.content-side .card {
  margin-bottom: 0;
}

.content-grid--two {
  grid-template-columns: 1fr;
}

.content-grid--two > * {
  min-width: 0;
}

.card--calendar .cal-grid {
  max-width: none;
}

/* ---------- Roster / table ---------- */

.roster {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 24px;
}

.content-grid .roster {
  margin-bottom: 0;
}

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

.section-head h2 {
  display: flex;
  align-items: center;
}

.count {
  font-size: 13px;
  font-weight: 400;
  background: var(--muted);
  padding: 3px 8px;
  border-radius: 8px;
  margin-left: 8px;
  color: var(--muted-foreground);
}

.button-group {
  display: flex;
  gap: 8px;
}

.roster-filters {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px 17px;
  gap: 12px;
  flex-wrap: wrap;
}

.sync-note {
  font-size: 12px;
  color: var(--muted-foreground);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  padding: 14px 24px;
}

.dark .table th {
  background: var(--muted);
}

.table td {
  padding: 16px 24px;
  font-size: 14px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: var(--muted);
}

.dark .table tbody tr:hover {
  background: var(--muted);
}

.table-empty {
  color: var(--muted-foreground);
  text-align: center;
  padding: 28px 24px !important;
}

.time-column {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted-foreground);
}

.person {
  display: flex;
  align-items: center;
  gap: 11px;
}

.person b {
  font-size: 14px;
  font-weight: 600;
}

.person small {
  display: block;
  font-size: 12px;
  color: var(--muted-foreground);
  letter-spacing: 0.4px;
  margin-top: 5px;
}

.dark .person small {
  color: var(--muted-foreground);
}

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--secondary);
  color: var(--muted-foreground);
  flex-shrink: 0;
  font-size: 16px;
}

.dark .avatar {
  background: var(--muted);
  color: var(--muted-foreground);
}

.status {
  font-size: 12px;
  color: var(--muted-foreground);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status:before {
  content: '';
  width: 5px;
  height: 5px;
  background: currentColor;
  border-radius: 50%;
}

.status.arrived {
  color: var(--success);
}

.dark .status {
  color: var(--muted-foreground);
}

/* ---------- Check-in card (voice) ---------- */

.checkin-card {
  background: var(--dark-panel);
  color: var(--panel-fg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
}

.checkin-card .eyebrow {
  color: var(--panel-muted);
  margin: 0;
}

.checkin-icon {
  font-size: 40px;
  line-height: 1;
}

.checkin-card h2 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--panel-fg);
}

.checkin-card p {
  font-size: 14px;
  line-height: 1.9;
  color: var(--panel-muted);
}

.checkin-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  border-radius: 9px;
  padding: 12px 14px;
  font-size: 15px;
  resize: vertical;
  min-height: 78px;
}

.checkin-input::placeholder {
  color: var(--muted-foreground);
}

.checkin-card button {
  width: 100%;
}

.checkin-card .btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: var(--panel-fg);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.checkin-card .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.checkin-card small {
  font-size: 12px;
  color: var(--panel-muted);
}

.checkin-card small.is-live {
  color: var(--success);
}

/* ---------- Filters ---------- */

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

.filter {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.filter:hover {
  background: var(--muted);
}

.filter.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

/* ---------- Calendar ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 24px;
}

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

.cal-title {
  font-size: 16px;
  font-weight: 700;
}

.cal-nav {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  border-radius: 9px;
  font-size: 18px;
}

.cal-nav:hover {
  background: var(--muted);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.cal-wd {
  text-align: center;
  font-size: 12px;
  color: var(--muted-foreground);
  padding: 6px 0;
}

.cal-cell {
  position: relative;
  min-height: 72px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  font-size: 14px;
  color: var(--foreground);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 3px;
  padding: 7px 9px;
  text-align: left;
}

.cal-cell:hover {
  background: var(--muted);
}

.cal-cell--empty {
  border-color: transparent;
  background: transparent;
}

.cal-cell.is-today {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.cal-cell.is-selected {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 700;
}

.cal-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.cal-dots {
  font-size: 10px;
  line-height: 1;
  letter-spacing: -1px;
}

.cal-detail {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.cal-detail-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}

.cal-detail-row {
  font-size: 14px;
  padding: 7px 0;
  color: var(--foreground);
}

.empty {
  color: var(--muted-foreground);
  font-size: 14px;
  padding: 4px 0;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  padding: 12px 18px;
  border-radius: 9px;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-outline {
  background: var(--card);
  border-color: var(--border);
  color: var(--foreground);
}

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

.btn-ghost {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-ghost:hover {
  background: var(--border);
}

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-text {
  background: transparent;
  color: var(--muted-foreground);
  font-weight: 500;
  font-size: 14px;
  text-decoration: underline;
}

.btn-mini {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}

.btn-small {
  flex: 0 0 auto;
}

/* ---------- Dialog ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(23, 37, 57, 0.45);
  z-index: 50;
}

.dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(94vw, 520px);
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 20px;
  padding: 28px;
  z-index: 51;
  box-shadow: 0 24px 70px rgba(23, 60, 130, 0.28);
}

.dialog-title {
  font-size: 22px;
  line-height: 1.4;
  font-weight: 750;
}

.dialog-desc {
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted-foreground);
  margin-top: 8px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.dialog-actions .btn {
  flex: 1;
}

.dialog-mic {
  width: 100%;
  margin-top: 18px;
}

.dialog-mic.is-recording {
  background: var(--destructive);
  color: #fff;
  border-color: var(--destructive);
}

.dialog-textarea {
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--foreground);
  font-size: 15px;
  resize: vertical;
  min-height: 96px;
}

.dialog-textarea::placeholder {
  color: var(--muted-foreground);
}

.dialog-status {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted-foreground);
}

.dialog-status.is-live {
  color: var(--primary);
}

.dialog--settings {
  max-height: 90dvh;
}

/* ---------- Result items ---------- */

.ci-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--muted);
  margin-top: 12px;
}

.ci-row__type,
.ci-row__title {
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--foreground);
  width: 100%;
}

.ci-row__title {
  font-weight: 600;
}

.ci-row__when {
  display: flex;
  gap: 8px;
}

.ci-row__when input {
  flex: 1;
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--foreground);
}

.ci-row__del {
  align-self: flex-start;
}

.ci-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted-foreground);
  cursor: pointer;
  line-height: 1.5;
}

.ci-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ---------- Form ---------- */

.field {
  display: block;
  margin: 18px 0 0;
}

.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 9px;
}

.field-select {
  width: 100%;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--foreground);
}

.field-row {
  display: flex;
  gap: 8px;
}

.field-row .field-select {
  flex: 1;
}

.diag {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted-foreground);
  background: var(--muted);
  border-radius: 9px;
  padding: 13px 15px;
}

.dark .diag {
  color: var(--muted-foreground);
  background: var(--muted);
}

.debug {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted-foreground);
}

.debug summary {
  cursor: pointer;
  padding: 6px 0;
}

.debug-pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--muted);
  border-radius: 9px;
  padding: 12px;
  max-height: 180px;
  overflow: auto;
  font-size: 12px;
  color: var(--foreground);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.sheet-close {
  border: none;
  background: transparent;
  font-size: 18px;
  color: var(--muted-foreground);
  padding: 6px 10px;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.sheet-actions--sub {
  margin-top: 10px;
}

.sheet-actions .btn {
  flex: 1;
}

/* ---------- Footer ---------- */

.footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted-foreground);
  padding: 30px 0 10px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: var(--foreground);
  color: var(--background);
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 10px;
  z-index: 70;
  box-shadow: 0 12px 30px rgba(23, 37, 57, 0.25);
  max-width: 90vw;
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
  .stats > div {
    padding: 0 18px;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: 60px;
    padding: 0 12px;
  }
  .brand {
    font-size: 17px;
    gap: 8px;
  }
  .brand-icon {
    width: 30px;
    height: 30px;
    font-size: 15px;
    border-radius: 9px;
  }
  .brand-en {
    display: none;
  }
  .topnote {
    gap: 6px;
  }
  .topbar-note {
    padding: 6px 10px;
    min-height: 32px;
    font-size: 12px;
  }
  .topbar-capture {
    padding: 6px 11px;
    min-height: 32px;
    font-size: 12px;
  }
  .topbar-icon {
    width: 32px;
    height: 32px;
  }
  .workspace {
    padding: 16px 12px 40px;
  }
  .heading {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 18px;
  }
  .heading h1 {
    font-size: 21px;
    letter-spacing: -0.5px;
  }
  .eyebrow {
    margin-bottom: 6px;
  }
  .heading .btn {
    width: 100%;
  }
  .event-strip {
    flex-wrap: wrap;
    padding: 14px 16px;
    gap: 12px;
  }
  .calendar-icon {
    padding: 10px;
    font-size: 18px;
  }
  .event-text h2 {
    font-size: 17px;
  }
  .event-strip p {
    margin-top: 3px;
    font-size: 13px;
  }
  .pill {
    padding: 4px 10px;
    font-size: 12px;
  }
  .stats {
    padding: 16px 0;
    margin: 18px 0;
  }
  .stats > div {
    padding: 0 6px;
  }
  .stats span {
    font-size: 11px;
    white-space: nowrap;
  }
  .stats strong {
    font-size: 20px;
    letter-spacing: -0.5px;
  }
  .stats small {
    font-size: 10px;
    margin-left: 2px;
  }
  .content-grid--two {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .card--calendar .cal-grid {
    max-width: 100%;
  }
  .content-main,
  .content-side {
    gap: 12px;
  }
  .section-head {
    padding: 12px;
  }
  .section-head h2 {
    font-size: 14px;
  }
  .roster-filters {
    padding: 0 12px 10px;
    gap: 6px;
  }
  .sync-note {
    display: none;
  }
  .count {
    font-size: 11px;
    padding: 2px 6px;
    margin-left: 5px;
  }
  .table th,
  .table td {
    padding: 8px 8px;
    font-size: 12px;
  }
  .person {
    gap: 6px;
    min-width: 0;
  }
  .person > div {
    min-width: 0;
  }
  .avatar {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
  .person b {
    font-size: 12px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .person small {
    font-size: 10px;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .btn-mini {
    min-height: 26px;
    padding: 3px 6px;
    font-size: 11px;
  }
  .card {
    padding: 12px;
    margin-bottom: 12px;
  }
  .content-side .card {
    margin-bottom: 0;
  }
  .cal-head {
    margin-bottom: 8px;
  }
  .cal-title {
    font-size: 13px;
  }
  .cal-nav {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  .cal-grid {
    gap: 2px;
  }
  .cal-wd {
    font-size: 10px;
    padding: 2px 0;
  }
  .cal-cell {
    font-size: 11px;
    border-radius: 6px;
    min-height: 48px;
    padding: 4px 5px;
    gap: 2px;
  }
  .cal-dots {
    font-size: 7px;
  }
  .cal-detail-title {
    font-size: 12px;
    margin-bottom: 6px;
  }
  .cal-detail-row {
    font-size: 12px;
    padding: 4px 0;
  }
  .filters {
    gap: 5px;
  }
  .filter {
    padding: 6px 10px;
    font-size: 12px;
  }
  .footer {
    font-size: 11px;
    padding: 20px 0 6px;
  }
  .dialog {
    width: 94vw;
    padding: 20px;
  }
}
