:root {
  color-scheme: light;
  --paper: #f7f5ef;
  --ink: #202026;
  --muted: #666a73;
  --line: #d9d3c5;
  --panel: #fffdf8;
  --panel-strong: #ffffff;
  --teal: #087f78;
  --teal-dark: #045d58;
  --coral: #e4553f;
  --gold: #d49a19;
  --blue: #2869ad;
  --shadow: 0 18px 50px rgba(39, 34, 24, 0.11);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(8, 127, 120, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(8, 127, 120, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1240px;
  margin: 0 auto 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
  letter-spacing: 0;
}

.brand img {
  width: 36px;
  height: 36px;
}

.status-pill,
.mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.8);
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(8, 127, 120, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 0.78fr) minmax(360px, 1fr);
  grid-template-areas:
    "tool preview"
    "vault preview"
    "file preview";
  gap: 16px;
  align-items: start;
  max-width: 1240px;
  margin: 0 auto;
}

.tool-panel,
.preview-panel,
.vault-panel,
.file-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.tool-panel {
  grid-area: tool;
  padding: 18px;
}

.preview-panel {
  grid-area: preview;
  padding: 18px;
  position: sticky;
  top: 18px;
}

.vault-panel {
  grid-area: vault;
  padding: 16px;
}

.file-panel {
  grid-area: file;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head.compact {
  align-items: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 840;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(34px, 5vw, 54px);
  max-width: 8ch;
}

h2 {
  font-size: 22px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

input[type="url"] {
  min-width: 0;
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
  outline: none;
}

input[type="url"]:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(8, 127, 120, 0.13);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 840;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  background: var(--teal);
  color: #fff;
}

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

.secondary-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.secondary-button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.notice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 14px 0 0;
  padding: 12px;
  border: 1px solid rgba(228, 85, 63, 0.27);
  border-radius: var(--radius);
  background: rgba(228, 85, 63, 0.07);
  color: #5e3028;
}

.notice p {
  margin: 0;
  font-size: 13px;
  line-height: 1.42;
  font-weight: 650;
}

.download-bar {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.download-bar .primary-button,
.download-bar .secondary-button {
  width: 100%;
}

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

.btn-sub {
  font-weight: 700;
  font-size: 12px;
  opacity: 0.72;
}

.dl-hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.result-actions .secondary-button {
  min-width: 0;
  padding: 0 10px;
}

.preview-stage {
  display: grid;
  place-items: center;
  min-height: 642px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #19191d;
  overflow: hidden;
}

.empty-preview {
  display: grid;
  place-items: center;
  gap: 18px;
  color: #f9f5ea;
  text-align: center;
  padding: 26px;
}

.empty-preview p {
  margin: 0;
  color: #eee5d7;
  font-weight: 760;
}

.phone-art {
  position: relative;
  width: 164px;
  aspect-ratio: 9 / 16;
  border: 2px solid rgba(249, 245, 234, 0.85);
  border-radius: 26px;
  background:
    linear-gradient(140deg, rgba(8, 127, 120, 0.92), rgba(40, 105, 173, 0.9) 46%, rgba(228, 85, 63, 0.92));
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
}

.phone-art::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  width: 44px;
  height: 5px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.74);
}

.phone-art span {
  position: absolute;
  left: 18px;
  right: 18px;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
}

.phone-art span:nth-child(1) {
  bottom: 52px;
}

.phone-art span:nth-child(2) {
  bottom: 34px;
  right: 54px;
}

.phone-art span:nth-child(3) {
  right: auto;
  left: 112px;
  bottom: 18px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
}

.preview-frame {
  width: min(100%, 420px);
  height: 642px;
  border: 0;
  background: #000;
}

.meta-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.meta-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 840;
  text-transform: uppercase;
}

.meta-strip strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vault-list {
  display: grid;
  gap: 10px;
}

.vault-empty {
  margin: 0;
  color: var(--muted);
  font-weight: 650;
}

.saved-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.saved-title {
  margin: 0;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.saved-meta {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.saved-actions .secondary-button {
  min-height: 36px;
  padding: 0 10px;
  font-size: 13px;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 132px;
  border: 1px dashed var(--teal);
  border-radius: var(--radius);
  background: rgba(8, 127, 120, 0.06);
  color: var(--teal-dark);
  font-weight: 850;
  cursor: pointer;
  text-align: center;
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-preview {
  margin-top: 12px;
}

.file-preview video,
.file-preview img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111;
}

.file-preview .secondary-button {
  width: 100%;
  margin-top: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid rgba(32, 32, 38, 0.12);
  border-radius: var(--radius);
  background: #202026;
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
  font-weight: 750;
  transition: transform 160ms ease, opacity 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.is-loading {
  opacity: 0.68;
  pointer-events: none;
}

@media (max-width: 930px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "tool"
      "preview"
      "vault"
      "file";
  }

  .preview-panel {
    position: static;
  }

  .preview-stage {
    min-height: 560px;
  }

  .preview-frame {
    height: 560px;
  }
}

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

  .topbar {
    margin-bottom: 12px;
  }

  .status-pill span:last-child {
    display: none;
  }

  .workspace {
    gap: 12px;
  }

  .tool-panel,
  .preview-panel,
  .vault-panel,
  .file-panel {
    padding: 14px;
  }

  h1 {
    font-size: 36px;
    max-width: 9ch;
  }

  .input-row,
  .result-actions {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .preview-stage {
    min-height: 520px;
  }

  .preview-frame {
    width: 100%;
    height: 520px;
  }

  .meta-strip {
    grid-template-columns: 1fr;
  }
}
