:root,
:root[data-theme="light"] {
  --bg-app: #f4f5f7;
  --bg-sidebar: #eef0f3;
  --bg-surface: #ffffff;
  --bg-muted: #f7f8fa;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-selected: color-mix(in srgb, var(--primary) 12%, white);
  --text-primary: #1c1c1e;
  --text-secondary: #636366;
  --text-tertiary: #8e8e93;
  --text-success: #34c759;
  --text-warning: #ff9f0a;
  --text-danger: #ff3b30;
  --primary: #007aff;
  --primary-foreground: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.12);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06);
  --titlebar-bg: linear-gradient(to bottom, #fafbfc, #f3f4f6);
  --window-outer-bg: #d8dde6;
  --secondary-btn-bg: rgba(0, 0, 0, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  --sidebar-width: 240px;
}

:root[data-theme="dark"] {
  --bg-app: #1c1c1e;
  --bg-sidebar: #161617;
  --bg-surface: #2c2c2e;
  --bg-muted: #3a3a3c;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-selected: color-mix(in srgb, var(--primary) 22%, #2c2c2e);
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #6c6c70;
  --text-success: #30d158;
  --text-warning: #ffd60a;
  --text-danger: #ff453a;
  --primary: #0a84ff;
  --primary-foreground: #ffffff;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.45);
  --titlebar-bg: linear-gradient(to bottom, #2c2c2e, #1c1c1e);
  --window-outer-bg: #0b0b0c;
  --secondary-btn-bg: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  padding: 24px;
  color: var(--text-primary);
  background: var(--window-outer-bg);
  font-family: var(--font-ui);
  font-size: 14px;
  transition: background-color 180ms ease, color 180ms ease;
}
button, a { font: inherit; }
button { color: inherit; }
svg { display: block; flex: 0 0 auto; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.window {
  width: min(1120px, 100%);
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg-app);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.titlebar {
  position: relative;
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 14px;
  background: var(--titlebar-bg);
  border-bottom: 1px solid var(--border);
}
.traffic-lights { display: flex; gap: 8px; }
.traffic-lights span { width: 12px; height: 12px; border-radius: 50%; }
.traffic-lights span:nth-child(1) { background: #ff5f57; }
.traffic-lights span:nth-child(2) { background: #febc2e; }
.traffic-lights span:nth-child(3) { background: #28c840; }
.titlebar-name { position: absolute; left: 50%; transform: translateX(-50%); color: var(--text-secondary); font-size: 13px; }
.titlebar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.icon-button {
  display: grid;
  width: 30px;
  height: 30px;
  margin-left: 0;
  padding: 0;
  place-items: center;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.icon-button:hover { color: var(--text-primary); background: var(--bg-hover); }
.mobile-only { display: none; }
.auth-view { display: grid; min-height: calc(100vh - 98px); padding: 32px; place-items: center; background: var(--bg-app); }
.auth-card { width: min(420px, 100%); padding: 30px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.auth-mark { display: grid; width: 44px; height: 44px; margin-bottom: 18px; place-items: center; color: var(--primary); background: var(--bg-muted); border: 1px solid var(--border); border-radius: 12px; }
.auth-mark svg { width: 23px; height: 23px; }
.auth-card h1 { margin-top: 7px; font-size: 21px; font-weight: 600; }
.auth-card > p:not(.auth-message) { margin-top: 8px; color: var(--text-secondary); line-height: 1.6; }
.auth-form { display: grid; gap: 14px; margin-top: 24px; }
.auth-form label, .config-form label { display: grid; gap: 6px; color: var(--text-secondary); font-size: 12px; }
input, select, textarea { width: 100%; padding: 9px 10px; color: var(--text-primary); background: var(--bg-muted); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); outline: 0; }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.auth-message { min-height: 18px; margin-top: 14px; color: var(--text-danger); font-size: 12px; line-height: 1.5; }
.text-button { padding: 0; color: var(--primary); background: transparent; border: 0; cursor: pointer; font-size: 12px; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-card > .text-button { display: block; margin-top: 16px; }

.shell { display: flex; min-height: calc(100vh - 98px); }
.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  padding: 20px 14px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; }
.brand-mark, .icon-plate {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--primary);
  background: var(--bg-muted);
  border: 1px solid var(--border);
}
.brand-mark { width: 36px; height: 36px; border-radius: 10px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 14px; font-weight: 600; }
.brand span { margin-top: 2px; color: var(--text-tertiary); font-size: 11px; }
.nav-label { display: block; padding: 0 10px 6px; color: var(--text-tertiary); font-size: 11px; }
.nav-item {
  display: flex;
  align-items: center;
  height: 38px;
  gap: 10px;
  padding: 0 10px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-item.active { color: var(--primary); background: var(--bg-selected); font-weight: 500; }
.nav-item svg { width: 17px; height: 17px; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 8px; color: var(--text-tertiary); font-size: 12px; }
.sidebar-logout { margin-left: auto; color: var(--text-tertiary); }
.connection-dot { width: 7px; height: 7px; background: var(--text-success); border-radius: 50%; }

.main { flex: 1; min-width: 0; background: var(--bg-app); }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 28px 28px 20px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
h1, h2, h3, p { margin: 0; }
.page-header h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; }
.page-header p { margin-top: 5px; color: var(--text-secondary); font-size: 13px; }
.content { display: grid; gap: 16px; padding: 0 28px 28px; }
.status-card, .notice-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.config-card { display: grid; gap: 20px; padding: 20px 22px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.config-card h2 { margin-top: 6px; font-size: 17px; font-weight: 600; }
.config-card > div > p { margin-top: 6px; color: var(--text-secondary); font-size: 12px; line-height: 1.6; }
.config-form { display: grid; gap: 14px; }
.site-login-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.config-help { color: var(--text-tertiary); font-size: 12px; line-height: 1.5; }
.auth-message.success { color: var(--text-success); }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.status-card { padding: 22px; }
.card-topline { display: flex; align-items: center; justify-content: space-between; }
.icon-plate { width: 42px; height: 42px; border-radius: 11px; }
.status-pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; color: var(--text-secondary); background: var(--bg-muted); border-radius: var(--radius-full); font-size: 11px; font-weight: 500; }
.status-pill.success { color: var(--text-success); background: color-mix(in srgb, var(--text-success) 12%, transparent); }
.status-pill.warning { color: var(--text-warning); background: color-mix(in srgb, var(--text-warning) 12%, transparent); }
.status-pill.danger { color: var(--text-danger); background: color-mix(in srgb, var(--text-danger) 12%, transparent); }
.activity-copy { padding: 22px 0 20px; }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 600; }
.activity-copy h2 { max-width: 720px; margin-top: 7px; font-size: 19px; line-height: 1.45; font-weight: 600; }
.activity-copy h2 a { color: inherit; text-decoration: none; }
.activity-copy h2 a[href]:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.activity-copy h2 a[href]:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 3px; }
.activity-copy p { margin-top: 8px; color: var(--text-secondary); line-height: 1.6; }
.meta-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; overflow: hidden; background: var(--bg-muted); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.meta-list div { padding: 13px 15px; }
.meta-list div + div { border-left: 1px solid var(--border); }
.meta-list dt { color: var(--text-tertiary); font-size: 11px; }
.meta-list dd { margin: 5px 0 0; color: var(--text-primary); font-size: 13px; font-weight: 500; }
.action-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 20px; }
.action-bar p { color: var(--text-tertiary); font-size: 12px; line-height: 1.5; }
.action-buttons { display: flex; flex-shrink: 0; gap: 8px; }
.button { display: inline-flex; align-items: center; justify-content: center; height: 34px; gap: 7px; padding: 0 13px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease; }
.button > svg { width: 18px; height: 18px; }
#share-proof-button { text-decoration: none; white-space: nowrap; }
.button:disabled { cursor: wait; opacity: 0.56; }
.button.primary { color: var(--primary-foreground); background: var(--primary); }
.button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 88%, var(--text-primary)); }
.button.ghost { color: var(--text-secondary); background: var(--bg-surface); border-color: var(--border); }
.button.ghost:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-hover); }
.button.danger { color: var(--text-danger); background: color-mix(in srgb, var(--text-danger) 9%, transparent); border-color: color-mix(in srgb, var(--text-danger) 20%, transparent); }
.button.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--text-danger) 15%, transparent); }
.notice-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 20px; }
.notice-card h3 { font-size: 14px; font-weight: 600; }
.notice-card p { max-width: 700px; margin-top: 5px; color: var(--text-secondary); font-size: 12.5px; line-height: 1.6; }
.notice-card > svg { flex: 0 0 auto; width: 22px; height: 22px; color: var(--text-tertiary); }
.hidden { display: none !important; }

@media (max-width: 760px) {
  body { padding: 0; }
  .window { min-height: 100vh; border: 0; border-radius: 0; }
  .titlebar { padding-right: max(10px, env(safe-area-inset-right)); padding-left: max(14px, env(safe-area-inset-left)); }
  .mobile-only { display: grid; }
  .icon-button { width: 40px; height: 40px; }
  .auth-view { min-height: calc(100vh - 48px); padding: 18px; }
  .auth-card { padding: 22px; }
  .shell { min-height: calc(100vh - 48px); }
  .sidebar { display: none; }
  .page-header { align-items: flex-start; padding: 24px max(18px, env(safe-area-inset-right)) 18px max(18px, env(safe-area-inset-left)); }
  .header-actions { gap: 6px; }
  .header-actions .button { width: 40px; height: 40px; padding: 0; }
  .header-actions .button > span { display: none; }
  .content { padding: 0 max(18px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
  .site-login-actions { flex-direction: column; }
  .site-login-actions .button { width: 100%; min-height: 40px; }
  .profile-grid { grid-template-columns: 1fr; }
  .status-card { padding: 18px; }
  .meta-list { grid-template-columns: 1fr; }
  .meta-list div + div { border-top: 1px solid var(--border); border-left: 0; }
  .action-bar { align-items: stretch; flex-direction: column; }
  .action-buttons { flex-direction: column; }
  .action-buttons, .action-buttons .button { width: 100%; }
  .action-buttons .button { min-height: 40px; }
  .notice-card { align-items: flex-start; }
}
