:root {
  --green: #35b286;
  --yellow: #ffd002;
  --charcoal: #222e29;
  --white: #ffffff;
  --mist: #f4f7f5;
  --line: #dce5df;
  --muted: #65736d;
  --danger: #b43232;
  --shadow: 0 18px 45px rgba(34, 46, 41, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--charcoal);
  background: var(--mist);
  font-family: "Poppins", Arial, sans-serif;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(34, 46, 41, 0.92);
}

.auth-card {
  display: grid;
  gap: 18px;
  width: min(100%, 430px);
  padding: 28px;
  background: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card .brand-lockup {
  width: 220px;
  max-width: 100%;
}

.auth-card h1 {
  font-size: 42px;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
}

.auth-error {
  min-height: 18px;
  color: var(--danger) !important;
  font-size: 13px;
  font-weight: 700;
}

.low-score-dialog {
  width: min(100% - 32px, 470px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.low-score-dialog::backdrop {
  background: rgba(34, 46, 41, 0.72);
}

.low-score-card {
  display: grid;
  gap: 16px;
  padding: 24px;
  background: var(--white);
}

.low-score-card h2 {
  font-size: 34px;
}

.low-score-card p {
  margin: 0;
  color: var(--muted);
}

.low-score-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px 20px;
  color: var(--white);
  background: var(--charcoal);
}

.brand-lockup {
  display: block;
  width: 210px;
  max-width: 100%;
}

.brand-lockup img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.primary-action,
.ghost-button,
.danger-button,
.small-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  color: var(--charcoal);
  background: var(--yellow);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: var(--charcoal);
  background: var(--white);
  border: 1px solid var(--line);
}

.sidebar .ghost-button {
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.danger-button {
  padding: 0 14px;
  color: var(--danger);
  background: #fff0f0;
  border: 1px solid #ffd1d1;
}

.small-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--charcoal);
  background: #e8f5ef;
  border: 1px solid #cce9dc;
}

.sidebar-section {
  min-height: 0;
}

.section-label,
.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.client-list {
  display: grid;
  gap: 8px;
}

.client-item {
  display: block;
  width: 100%;
  padding: 12px;
  color: var(--white);
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid transparent;
  border-radius: 8px;
}

.client-item strong,
.client-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-item span {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.client-item.active {
  color: var(--charcoal);
  background: var(--green);
}

.client-item.active span {
  color: rgba(34, 46, 41, 0.78);
}

.sidebar-tools {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

#importInput {
  display: none;
}

.hidden-file {
  display: none;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 30px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Oswald", Arial, sans-serif;
  line-height: 1.05;
}

h1 {
  max-width: 780px;
  font-size: clamp(38px, 5vw, 72px);
}

h2 {
  font-size: 30px;
}

h3 {
  font-size: 22px;
}

.save-state {
  padding: 10px 14px;
  color: var(--charcoal);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(340px, 0.95fr);
  gap: 22px;
  align-items: start;
}

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

.editor-panel,
.prompt-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.panel-header,
.row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--charcoal);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--charcoal);
  background: #fbfdfc;
  outline: none;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(53, 178, 134, 0.16);
}

.color-editor {
  display: grid;
  gap: 12px;
}

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

.color-row {
  display: grid;
  grid-template-columns: 44px 1fr 118px 36px;
  gap: 10px;
  align-items: center;
}

.color-row input[type="color"] {
  height: 44px;
  padding: 4px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--danger);
  background: var(--white);
  font-weight: 700;
}

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

.brief-quality-panel {
  width: min(100%, 430px);
}

.brief-generate-muted {
  color: #6d746f !important;
  background: #d7ddd9 !important;
  box-shadow: none !important;
}

.text-limit-error {
  color: var(--danger) !important;
}

.hard-disabled {
  cursor: not-allowed !important;
  opacity: 0.62;
}

.prompt-output,
.payload-output {
  min-height: 300px;
  color: var(--white);
  background: var(--charcoal);
  border-color: var(--charcoal);
}

.payload-output {
  min-height: 220px;
  margin-top: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.payload-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.payload-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.preset-button {
  min-height: 74px;
  padding: 11px;
  text-align: left;
  color: var(--charcoal);
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preset-button strong,
.preset-button span {
  display: block;
}

.preset-button strong {
  font-size: 13px;
}

.preset-button span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.preset-button.active {
  border-color: var(--green);
  background: #e8f5ef;
  box-shadow: inset 0 0 0 2px rgba(53, 178, 134, 0.18);
}

.reference-block {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.helper-text {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.upload-box {
  min-height: 86px;
  align-content: center;
  padding: 14px;
  color: var(--charcoal);
  background: var(--white);
  border: 1px dashed var(--green);
  border-radius: 8px;
  cursor: pointer;
}

.upload-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.asset-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.asset-card {
  display: grid;
  gap: 8px;
  padding: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.asset-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #edf4f0;
  border-radius: 6px;
}

.asset-card strong,
.asset-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-card strong {
  font-size: 12px;
}

.asset-card span {
  color: var(--muted);
  font-size: 11px;
}

.asset-card button {
  min-height: 30px;
  color: var(--danger);
  background: #fff7f7;
  border: 1px solid #ffd1d1;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.history-block {
  display: grid;
  gap: 12px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  text-align: left;
  color: var(--charcoal);
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item span {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  margin: 0;
  padding: 12px;
  color: var(--muted);
  background: #fbfdfc;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.asset-preview-grid .empty-state {
  grid-column: 1 / -1;
}

.preview-band {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 360px);
  gap: 22px;
  align-items: center;
  padding: 24px;
  color: var(--white);
  background: var(--green);
  border-radius: 8px;
}

.preview-copy .eyebrow {
  color: var(--charcoal);
}

.preview-copy p:last-child {
  max-width: 760px;
  margin: 10px 0 0;
}

.swatch-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.preview-swatch {
  min-height: 92px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
}

@media (max-width: 980px) {
  .app-shell,
  .editor-layout,
  .preview-band {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .workspace,
  .sidebar {
    padding: 20px;
  }

  .topbar,
  .panel-header,
  .row-title {
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid,
  .color-row,
  .preset-grid,
  .asset-preview-grid {
    grid-template-columns: 1fr;
  }

  .color-row input[type="color"],
  .icon-button {
    width: 100%;
  }
}
