:root {
  color-scheme: light;
  --ink: #182226;
  --muted: #5d6a70;
  --line: #d9e1e4;
  --panel: #ffffff;
  --panel-soft: #f5f8f7;
  --accent: #0c7c74;
  --accent-strong: #075f59;
  --amber: #c96f1a;
  --shadow: 0 18px 50px rgba(24, 34, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background:
    linear-gradient(120deg, rgba(12, 124, 116, 0.12), transparent 38%),
    linear-gradient(290deg, rgba(201, 111, 26, 0.11), transparent 34%),
    #edf2ef;
  color: var(--ink);
}

button,
select,
textarea {
  font: inherit;
}

button,
a {
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 0 14px;
  min-height: 40px;
  cursor: pointer;
}

button:hover,
a:hover {
  transform: translateY(-1px);
}

.shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 16px;
  min-height: calc(100vh - 36px);
}

.input-pane,
.compare-pane {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(217, 225, 228, 0.85);
  box-shadow: var(--shadow);
}

.input-pane {
  position: sticky;
  top: 18px;
  align-self: start;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 36px);
  border-radius: 8px;
  padding: 22px;
}

.brand-row,
.toolbar,
.site-card header,
.controls,
.bulk-actions {
  display: flex;
  align-items: center;
}

.brand-row,
.toolbar,
.site-card header {
  justify-content: space-between;
  gap: 12px;
}

.eyebrow,
.site-kind,
.toolbar p,
.status-line {
  color: var(--muted);
  margin: 0;
  font-size: 0.82rem;
}

.eyebrow,
.site-kind {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.65rem, 2.8vw, 2.4rem);
}

h2 {
  font-size: 1.18rem;
}

h3 {
  font-size: 1rem;
}

.live-dot {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 7px rgba(12, 124, 116, 0.14);
}

.field-label {
  margin-top: 34px;
  margin-bottom: 10px;
  font-weight: 750;
}

textarea {
  flex: 1;
  min-height: 310px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfdfc;
  color: var(--ink);
  line-height: 1.7;
  outline: none;
}

textarea:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(12, 124, 116, 0.22);
  outline-offset: 2px;
}

.controls {
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.select-wrap {
  display: grid;
  grid-template-columns: auto minmax(130px, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding-left: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

select {
  border: 0;
  min-height: 38px;
  padding: 0 12px;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.bulk-actions {
  gap: 10px;
  margin-top: 12px;
}

.bulk-actions button:first-child {
  flex: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 750;
}

.bulk-actions button:first-child:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.status-line {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.site-picker {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.picker-head,
.picker-actions,
.picker-item {
  display: flex;
  align-items: center;
}

.picker-head {
  justify-content: space-between;
  gap: 10px;
}

.picker-head h2 {
  font-size: 0.98rem;
}

.picker-head button,
.picker-actions button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
}

.picker-actions {
  gap: 8px;
  margin-top: 10px;
}

.picker-actions button {
  flex: 1;
}

.picker-list {
  display: grid;
  gap: 7px;
  max-height: 280px;
  margin-top: 10px;
  padding-right: 4px;
  overflow: auto;
}

.picker-item {
  min-height: 36px;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid rgba(217, 225, 228, 0.8);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.picker-item input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.picker-item span {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
}

.picker-item small {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.compare-pane {
  min-width: 0;
  border-radius: 8px;
  padding: 16px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 4px 4px 16px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.97), rgba(255, 255, 255, 0.82));
  backdrop-filter: blur(12px);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

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

.site-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.site-card[hidden] {
  display: none;
}

.site-card header {
  min-height: 70px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

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

.frame-tools {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, auto));
  gap: 6px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fafcfb;
}

.frame-tools button {
  min-height: 32px;
  padding: 0 9px;
  color: var(--muted);
  border-color: rgba(93, 106, 112, 0.2);
}

.frame-tools button:hover {
  color: var(--accent-strong);
  border-color: rgba(12, 124, 116, 0.32);
}

.frame-tools button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.frame-locked .lock-btn {
  background: rgba(12, 124, 116, 0.1);
  color: var(--accent-strong);
  border-color: rgba(12, 124, 116, 0.32);
}

.focus-btn {
  min-height: 36px;
  padding: 0 10px;
  color: var(--accent-strong);
  border-color: rgba(12, 124, 116, 0.24);
  font-weight: 750;
  white-space: nowrap;
}

.site-card a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(12, 124, 116, 0.24);
  border-radius: 8px;
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 750;
  white-space: nowrap;
}

.site-card a:hover {
  background: rgba(12, 124, 116, 0.09);
}

.frame-shell {
  position: relative;
  height: 440px;
  overflow: hidden;
  background: #eef3f2;
}

iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

.focus-output iframe {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--frame-width);
  height: var(--frame-height);
  transform: translate(var(--frame-x), var(--frame-y)) scale(var(--frame-scale));
  transform-origin: top left;
}

.frame-cover {
  position: absolute;
  inset: auto 14px 14px 14px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(217, 225, 228, 0.94);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 30px rgba(24, 34, 38, 0.12);
}

.frame-cover p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.preview-off iframe {
  display: none;
}

.preview-off .frame-shell {
  height: 128px;
}

.preview-off .frame-cover {
  display: flex;
}

@media (max-width: 980px) {
  .workspace,
  .site-grid {
    grid-template-columns: 1fr;
  }

  .input-pane {
    position: relative;
    top: auto;
    min-height: auto;
  }

  textarea {
    min-height: 230px;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 10px;
  }

  .input-pane,
  .compare-pane {
    padding: 14px;
  }

  .toolbar,
  .brand-row {
    align-items: flex-start;
  }

  .toolbar {
    gap: 10px;
  }

  .bulk-actions,
  .controls,
  .frame-cover {
    flex-direction: column;
    align-items: stretch;
  }

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

  .select-wrap {
    width: 100%;
  }

  button,
  .site-card a {
    width: 100%;
  }

  .frame-shell {
    height: 390px;
  }
}
