:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --ink: #111317;
  --muted: #606873;
  --line: #dedbd2;
  --panel: #ffffff;
  --panel-soft: #f2f7f5;
  --accent: #0e6b5f;
  --accent-2: #b74b33;
  --accent-3: #244d7a;
  --shadow: 0 18px 50px rgba(25, 28, 35, 0.12);
  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: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100vh - 40px);
}

.sidebar {
  background: #151819;
  color: #f9fbf8;
  border-radius: 8px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #e8c468;
  color: #151819;
  font-weight: 800;
}

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

h1 {
  font-size: 20px;
  line-height: 1.15;
}

.brand p,
.model-note dd,
.api-note p {
  color: #c6ccc8;
  line-height: 1.6;
  font-size: 14px;
}

.model-note,
.api-note,
.history-note {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 18px;
}

.model-note h2,
.api-note h2,
.history-note h2 {
  font-size: 15px;
  margin-bottom: 12px;
}

dt {
  color: #ffffff;
  font-weight: 700;
  margin-top: 14px;
}

dd {
  margin: 6px 0 0;
}

code {
  color: #0f5d54;
  background: rgba(14, 107, 95, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
}

.sidebar code {
  color: #e8c468;
  background: rgba(232, 196, 104, 0.12);
}

.api-note a {
  display: block;
  color: #f3d787;
  margin-top: 10px;
  text-decoration: none;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-head button,
.history-delete {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #f9fbf8;
  min-height: 30px;
  border-radius: 6px;
  cursor: pointer;
  padding: 0 9px;
  font-size: 12px;
}

.history-list {
  display: grid;
  gap: 10px;
  max-height: 44vh;
  overflow: auto;
  padding-right: 3px;
}

.history-empty {
  color: #c6ccc8;
  font-size: 13px;
  line-height: 1.5;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 9px;
}

.history-open {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.history-top {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
  font-size: 12px;
}

.history-top time,
.history-output {
  color: #aeb8b4;
}

.history-prompt,
.history-output {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.history-prompt {
  color: #eef4f0;
}

.tool {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #faf9f5;
}

.tab,
.primary,
.secondary {
  border: 0;
  cursor: pointer;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 700;
}

.tab {
  background: transparent;
  color: var(--muted);
}

.tab.is-active {
  color: #ffffff;
  background: var(--ink);
}

.panel {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 112px);
}

.panel.is-hidden {
  display: none;
}

.form {
  padding: 22px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fffdf9;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

label {
  color: #333840;
  font-size: 13px;
  font-weight: 750;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #d6d3ca;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 107, 95, 0.12);
}

.file-row {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.upload-status {
  display: grid;
  gap: 8px;
}

.upload-item {
  display: grid;
  gap: 4px;
  padding: 9px;
  border: 1px solid #d6d3ca;
  border-radius: 8px;
  background: #f7fbf9;
  color: #333840;
}

.upload-item span {
  font-weight: 700;
}

.upload-item a {
  color: var(--accent-3);
  overflow-wrap: anywhere;
}

.primary {
  background: var(--accent);
  color: #ffffff;
}

.primary:disabled,
.secondary:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.secondary {
  background: #eef2ef;
  color: var(--accent);
}

.result {
  padding: 22px;
  min-width: 0;
  background: linear-gradient(180deg, #f4f8f7 0%, #ffffff 45%);
  overflow: auto;
}

.empty-state {
  display: grid;
  gap: 16px;
  place-items: center;
  min-height: 460px;
  text-align: center;
  color: var(--muted);
}

.media-placeholder {
  width: min(100%, 560px);
  aspect-ratio: 16 / 10;
  border: 1px solid rgba(17, 19, 23, 0.12);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: #d8e2df;
}

.image-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(145deg, transparent 0 35%, rgba(255, 255, 255, 0.9) 35% 36%, transparent 36%),
    radial-gradient(circle at 72% 28%, #e8c468 0 7%, transparent 8%),
    linear-gradient(155deg, #244d7a 0 42%, #0e6b5f 42% 66%, #b74b33 66% 100%);
}

.video-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0 8%, transparent 8% 92%, rgba(0, 0, 0, 0.2) 92%),
    linear-gradient(160deg, #0e6b5f, #e8c468 52%, #244d7a);
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  margin-bottom: 16px;
}

.status.inline {
  margin-bottom: 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #cfd8d5;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.output {
  display: grid;
  gap: 16px;
}

.output img,
.output video {
  width: min(100%, 760px);
  max-height: 70vh;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #101214;
}

.meta {
  display: grid;
  gap: 10px;
  width: min(100%, 760px);
}

.meta-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.meta-row strong {
  color: var(--ink);
}

.meta-row a {
  color: var(--accent-3);
  overflow-wrap: anywhere;
}

pre {
  width: min(100%, 760px);
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: #151819;
  color: #edf3ef;
  line-height: 1.45;
  font-size: 12px;
}

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

.error {
  color: #7a2518;
  background: #fff0ec;
  border: 1px solid #efc4b9;
  padding: 14px;
  border-radius: 8px;
  line-height: 1.55;
}

.error.compact {
  padding: 10px;
}

@media (max-width: 980px) {
  .shell {
    padding: 0;
  }

  .workspace,
  .panel {
    grid-template-columns: 1fr;
  }

  .workspace {
    min-height: 100vh;
    gap: 0;
  }

  .sidebar,
  .tool {
    border-radius: 0;
  }

  .form {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .tab {
    flex: 1;
    padding: 0 10px;
  }
}
