:root {
  --bg: #f5f7f9;
  --card: #ffffff;
  --text: #2d2d2f;
  --muted: #8e8e93;
  --warning: #f2994a;
  --accent: #007aff;
  --info-bg: #ebf3ff;
  --font: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --title-size: 17px;
  --label-size: 14px;
  --body-size: 14px;
  --warn-size: 13px;
  --editor-bg: #111318;
  --editor-panel: #1a1d24;
  --editor-border: #2a2f3a;
  --editor-text: #e8eaed;
  --editor-muted: #9aa0a6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: #0d0f12;
  color: var(--editor-text);
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: 1fr min(400px, 42vw);
  height: 100vh;
}

/* ========== Preview ========== */
.preview-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, #1a2230 0%, transparent 55%),
    #0d0f12;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.preview-toolbar h1,
.editor-header h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  color: inherit;
}

.btn-primary {
  background: #3b82f6;
  color: #fff;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--editor-text);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.phone-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
}

.phone {
  width: 390px;
  border-radius: 40px;
  padding: 12px;
  background: linear-gradient(160deg, #2a2d35, #1a1c22);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 30px 80px rgba(0, 0, 0, 0.55);
}

.phone-screen {
  position: relative;
  background: var(--bg);
  border-radius: 32px;
  overflow: hidden;
  height: 780px;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

/* Status bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px 6px 32px;
  font-size: 15px;
  font-weight: 600;
  color: #1c1c1e;
  letter-spacing: -0.02em;
}

.status-icons {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #1c1c1e;
}

.network-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  line-height: 1;
}

.network-type-text {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.network-wifi-icon {
  display: block;
  flex-shrink: 0;
}

.network-slot.is-wifi .network-type-text {
  display: none;
}

.network-slot:not(.is-wifi) .network-wifi-icon {
  display: none;
}

.battery {
  display: flex;
  align-items: center;
  margin-left: 2px;
}

.battery-body {
  width: 22px;
  height: 11px;
  border: 1.2px solid #1c1c1e;
  border-radius: 3px;
  padding: 1.5px;
  opacity: 0.9;
}

.battery-level {
  height: 100%;
  width: 100%;
  background: #1c1c1e;
  border-radius: 1px;
}

.battery-cap {
  width: 1.5px;
  height: 4px;
  background: #1c1c1e;
  border-radius: 0 1px 1px 0;
  margin-left: 1px;
  opacity: 0.55;
}

.battery-text[hidden] {
  display: none !important;
}

/* Nav */
.nav {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 4px 8px 10px;
}

.nav-close {
  width: 44px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #6b6b70;
  cursor: default;
}

.nav-title {
  text-align: center;
  font-size: var(--title-size);
  font-weight: 600;
  color: #4a4a4e;
  letter-spacing: 0.01em;
}

.nav-spacer {
  width: 44px;
}

.content {
  flex: 1;
  padding: 4px 20px 8px;
}

.warning {
  text-align: center;
  color: var(--warning);
  font-size: var(--warn-size);
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 18px;
  letter-spacing: 0.01em;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 4px 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid #f0f1f3;
}

.row:last-child {
  border-bottom: none;
}

.label {
  flex-shrink: 0;
  color: var(--muted);
  font-size: var(--label-size);
  font-weight: 400;
  line-height: 1.45;
  padding-top: 1px;
}

.value {
  text-align: right;
  color: var(--text);
  font-size: var(--body-size);
  font-weight: 400;
  line-height: 1.45;
  word-break: break-all;
  max-width: 62%;
}

.value.mono {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.value-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 6px;
  max-width: 68%;
}

.value-wrap .value {
  max-width: none;
}

.copy-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  opacity: 0.95;
}

.copy-btn:hover {
  opacity: 0.7;
}

/* Chevrons */
.chevrons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 0;
}

.chevrons span {
  width: 10px;
  height: 10px;
  border-right: 2px solid #c8ccd2;
  border-bottom: 2px solid #c8ccd2;
  transform: rotate(45deg);
  margin-top: -5px;
}

.chevrons span:first-child {
  margin-top: 0;
  opacity: 0.55;
}

.chevrons span:nth-child(2) {
  opacity: 0.75;
}

.chevrons span:last-child {
  opacity: 1;
}

/* Limits */
.limits {
  margin-top: 28px;
  padding: 0 2px;
}

.limits-title {
  font-size: 16px;
  font-weight: 600;
  color: #3a3a3c;
  margin-bottom: 16px;
}

.limit-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  font-size: 14px;
}

.limit-label {
  color: var(--muted);
}

.limit-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* Info banner */
.info-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--info-bg);
  border-radius: 12px;
  text-decoration: none;
  color: #4a5568;
  font-size: 13.5px;
  line-height: 1.4;
}

.info-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
}

.info-link {
  color: var(--accent);
  font-weight: 500;
}

.footer-note {
  display: flex;
  gap: 6px;
  margin-top: 18px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.footer-note .dot {
  flex-shrink: 0;
  color: #b0b4bb;
}

.home-indicator {
  width: 134px;
  height: 5px;
  background: #1c1c1e;
  border-radius: 100px;
  margin: 18px auto 10px;
  opacity: 0.9;
}

/* ========== Editor ========== */
.editor-pane {
  display: flex;
  flex-direction: column;
  background: var(--editor-panel);
  border-left: 1px solid var(--editor-border);
  min-height: 0;
}

.editor-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--editor-border);
}

.editor-header p {
  margin-top: 6px;
  font-size: 12px;
  color: var(--editor-muted);
  line-height: 1.45;
}

.editor-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 32px;
}

.editor-scroll details {
  border: 1px solid var(--editor-border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.editor-scroll summary {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
  color: #d0d4db;
}

.editor-scroll summary::-webkit-details-marker {
  display: none;
}

.editor-scroll summary::after {
  content: '▾';
  float: right;
  opacity: 0.45;
  font-size: 11px;
}

.editor-scroll details:not([open]) summary::after {
  content: '▸';
}

.editor-scroll details[open] summary {
  border-bottom: 1px solid var(--editor-border);
}

.field {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 11px;
  color: var(--editor-muted);
  display: flex;
  justify-content: space-between;
}

.field input[type='text'],
.field textarea,
.field select,
.field .hex {
  width: 100%;
  background: #0f1115;
  border: 1px solid var(--editor-border);
  border-radius: 7px;
  color: var(--editor-text);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 10px;
  outline: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.field .hex:focus {
  border-color: #3b82f6;
}

.field textarea {
  resize: vertical;
  min-height: 56px;
  line-height: 1.45;
}

.color-field {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.color-field label {
  flex: 1 1 100%;
}

.color-field input[type='color'] {
  width: 36px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--editor-border);
  border-radius: 6px;
  background: #0f1115;
  cursor: pointer;
}

.color-field .hex {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.field input[type='range'] {
  width: 100%;
  accent-color: #3b82f6;
}

.range-val {
  color: #8ab4f8;
  font-variant-numeric: tabular-nums;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(30, 30, 34, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  pointer-events: none;
}

.toast[hidden] {
  display: none;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .preview-pane {
    min-height: 100vh;
  }

  .editor-pane {
    border-left: none;
    border-top: 1px solid var(--editor-border);
    max-height: none;
  }

  .editor-scroll {
    max-height: none;
  }
}
