/* Hallmark · Workbench · side rail · corporate blue and cool gray */
:root {
  --paper: #f8f9fc;
  --rail: #f0f2f7;
  --surface: #fff;
  --ink: #192338;
  --muted: #525f74;
  --quiet: #64748b;
  --line: #dbe1eb;
  --line-strong: #bcc7d8;
  --placeholder: #eef2f8;
  --placeholder-border: #dce4f0;
  --placeholder-icon: #96a7be;
  --brand: #1677f2;
  --accent: #0e6bdd;
  --accent-hover: #0959bf;
  --accent-soft: #e6f1fe;
  --on-accent: #fff;
  --shadow: 0 12px 28px -22px rgb(26 43 77 / 42%);
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; }
[hidden] { display: none !important; }

body {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
}

button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:where(button, a, summary):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon-library { position: absolute; width: 0; height: 0; }
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar {
  min-width: 0;
  padding: 28px 16px;
  background: var(--rail);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  margin: 0 12px 39px;
  font-size: 26px;
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.brand-logo {
  display: block;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 10px;
}

.tools-label {
  margin: 0 12px 8px;
  color: var(--quiet);
  font-size: 12px;
  font-weight: 650;
}

.tool {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
}

.history-shortcut {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  gap: 9px;
  margin-top: 23px;
  padding: 6px 10px;
  border: 1px solid var(--brand);
  border-radius: 9px;
  background: var(--surface);
  color: var(--accent-hover);
  font-weight: 680;
}
.history-shortcut:hover { background: var(--accent-soft); }
.history-shortcut-icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
}
.history-shortcut-icon .icon { width: 19px; height: 19px; }
.history-shortcut-arrow {
  width: 15px;
  height: 15px;
  margin-inline-start: auto;
}

.workspace {
  width: min(100%, 1180px);
  min-width: 0;
  margin-inline: auto;
  padding: clamp(40px, 5.2vw, 70px) clamp(28px, 5vw, 76px) 64px;
}
.photo-studio,
.library {
  max-width: 890px;
  margin-inline: auto;
}

h1, h2 { margin: 0; overflow-wrap: anywhere; }
h1 {
  margin-bottom: 23px;
  font-size: clamp(32px, 5vw, 47px);
  font-weight: 690;
  line-height: 1.1;
  letter-spacing: -0.052em;
}

.photo-mode-picker {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 39px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}
.photo-pill {
  display: inline-flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 620;
  text-align: center;
  overflow-wrap: anywhere;
}
.photo-pill .icon { width: 16px; height: 16px; }
.photo-pill:hover { background: var(--paper); color: var(--ink); }
.photo-pill[aria-pressed="true"] {
  border-color: var(--line-strong);
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.photo-mode-heading { margin-bottom: 28px; text-align: center; }
.photo-mode-heading h1 {
  margin: 0 0 9px;
  font-size: clamp(29px, 4.5vw, 43px);
  letter-spacing: -0.046em;
}
.photo-mode-heading p { margin: 0; color: var(--muted); }

.composer {
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer:focus-within { border-color: var(--brand); }
.composer textarea {
  display: block;
  width: 100%;
  min-height: 124px;
  padding: 21px 22px 10px;
  resize: vertical;
  border: 0;
  border-radius: 14px 14px 0 0;
  background: transparent;
  font-size: 17px;
  outline: none;
}

.composer textarea::placeholder { color: var(--quiet); opacity: 1; }
.composer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.composer-controls { display: flex; max-width: 100%; align-items: center; gap: 8px; }
.photo-format {
  display: flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  gap: 6px;
  padding-inline: 9px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}
.photo-format .icon { width: 17px; height: 17px; }
.photo-format select {
  max-width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.photo-format select:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.attach-button, .generate {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 620;
  white-space: nowrap;
}

.attach-button:hover { border-color: var(--accent); color: var(--accent); }
.attach-button .icon, .generate .icon { width: 17px; height: 17px; }
.file-menu { position: relative; }
.file-menu summary { cursor: pointer; list-style: none; }
.file-menu summary .icon {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}
.file-menu summary::-webkit-details-marker { display: none; }
.file-menu[open] summary { border-color: var(--accent); color: var(--accent); }

.file-options {
  position: absolute;
  z-index: 2;
  inset-block-start: calc(100% + 6px);
  inset-inline-start: 0;
  width: 190px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.file-option {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  text-align: left;
}
.file-option:hover { background: var(--accent-soft); color: var(--accent-hover); }
.file-option .icon { width: 17px; height: 17px; }
.file-options > span {
  display: block;
  padding: 0 10px 5px 36px;
  color: var(--muted);
  font-size: 12px;
}

.generate {
  margin-inline-start: auto;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.generate:hover:not(:disabled) { border-color: var(--accent-hover); background: var(--accent-hover); }
.generate:disabled { cursor: not-allowed; opacity: 0.56; }

.background-form {
  display: grid;
  gap: 12px;
  padding: 14px;
}
.background-dropzone {
  display: grid;
  min-width: 0;
  justify-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  background: var(--paper);
}
.background-dropzone:hover,
.background-dropzone.is-dragging {
  border-color: var(--brand);
  background: var(--accent-soft);
}
.background-choose {
  display: flex;
  width: 100%;
  min-height: 153px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--accent-hover);
}
.background-choose > .icon { width: 23px; height: 23px; margin-bottom: 3px; }
.background-drop-hint { color: var(--muted); font-size: 13px; }
.background-dropzone.has-photo { gap: 5px; padding: 9px; }
.background-dropzone.has-photo .background-choose {
  width: auto;
  min-height: 38px;
  padding: 5px 13px;
}
.background-dropzone.has-photo .background-choose > .icon,
.background-dropzone.has-photo .background-drop-hint { display: none; }
.background-preview {
  display: flex;
  max-width: 100%;
  min-width: 0;
  align-items: center;
  gap: 8px;
}
.background-preview img { flex: none; border-radius: 7px; object-fit: cover; }
.background-preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.background-form > .generate { width: 100%; }

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 12px;
}

.attachment {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font-size: 13px;
}

.attachment img { border-radius: 4px; object-fit: cover; }
.attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment .icon { width: 16px; height: 16px; }
.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  flex: none;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
}
.icon-button:hover { color: var(--accent); }

.status {
  min-height: 1.5em;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.photo-examples { margin-top: 12px; }
.photo-examples p { margin: 0 0 9px; color: var(--ink); font-size: 14px; font-weight: 670; }
.photo-examples [role="group"] {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.photo-example {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 14px;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  gap: 9px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 610;
  text-align: left;
  overflow-wrap: anywhere;
}
.photo-example .icon { width: 16px; height: 16px; color: var(--accent-hover); }
.photo-example .photo-example-arrow { width: 14px; height: 14px; color: var(--quiet); }
.photo-example:hover,
.photo-example[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.library { margin-top: 44px; }
.library-heading {
  margin-bottom: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.library-heading h2 {
  font-size: clamp(21px, 3vw, 27px);
  font-weight: 680;
  letter-spacing: -0.035em;
  line-height: 1.2;
}
.library-heading p { margin: 5px 0 0; color: var(--muted); }
.template-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.template {
  display: block;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--quiet);
  text-decoration: none;
  transition: border-color 130ms ease, color 130ms ease;
}
.template:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.template-preview {
  position: relative;
  display: grid;
  aspect-ratio: 4 / 3;
  place-items: center;
  background: var(--placeholder);
  color: var(--placeholder-icon);
}
.template-preview::before {
  position: absolute;
  inset: 10px;
  border: 1px dashed var(--placeholder-border);
  border-radius: 5px;
  content: "";
}
.template-preview .icon { width: 27px; height: 27px; stroke-width: 1.35; }
.template-footer {
  display: flex;
  min-height: 45px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
}
.template-footer span {
  width: 45%;
  height: 7px;
  border-radius: 4px;
  background: var(--placeholder-border);
}
.template-footer .icon { width: 17px; height: 17px; }

body:is([data-template-open], [data-generation-open]) { display: block; }

.detail-screen {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  gap: 12px;
  width: min(100%, 1400px);
  margin-inline: auto;
  padding: 16px;
}

.detail-panel {
  min-width: 0;
  padding: clamp(16px, 2.3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}
.detail-media { background: var(--rail); }

.detail-back {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  padding-inline: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.detail-back:hover { border-color: var(--brand); color: var(--accent); }
.detail-back .icon { width: 16px; height: 16px; transform: rotate(180deg); }

.detail-preview {
  display: grid;
  min-height: clamp(380px, 48vw, 590px);
  justify-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--placeholder);
}

.detail-preview-placeholder {
  display: grid;
  width: min(68%, 330px);
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 16px;
  border-inline: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}
.detail-preview-placeholder .icon { width: 36px; height: 36px; }

.detail-settings, .detail-form { display: flex; flex-direction: column; }
.detail-settings h1 {
  margin: 2px 0 24px;
  font-size: clamp(30px, 3.3vw, 42px);
  font-weight: 680;
  letter-spacing: -0.03em;
}
.detail-settings h1:focus { outline: none; }

.detail-tip {
  margin-bottom: 24px;
  padding: 15px 17px;
  border-radius: 12px;
  background: var(--accent-soft);
}
.detail-tip strong { font-size: 14px; }
.detail-tip p { margin: 4px 0 0; color: var(--muted); }

.detail-form { flex: 1; gap: 24px; }
.detail-field-title {
  margin-bottom: 9px;
  font-size: 15px;
  font-weight: 650;
}
.detail-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
}
.detail-upload-icon {
  display: grid;
  width: 48px;
  height: 48px;
  flex: none;
  place-items: center;
  border-radius: 8px;
  background: var(--rail);
}
.detail-upload-copy { flex: 1 0 auto; }
.detail-upload-copy p { margin: 0; font-weight: 620; }
.detail-upload-copy span { color: var(--muted); font-size: 13px; }
.detail-upload .attach-button { color: var(--accent); }

.detail-attachment {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.detail-attachment img { border-radius: 4px; object-fit: cover; }
.detail-attachment span { flex: 1; overflow-wrap: anywhere; }

.detail-submit { margin-top: auto; }
.detail-submit .status { margin: 0 0 8px; }
.detail-generate {
  width: 100%;
  min-height: 48px;
  font-size: 15px;
}

.generation-screen {
  display: grid;
  grid-template-columns: minmax(208px, 256px) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  padding: 16px;
}
.generation-side {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--rail);
}
.generation-back { margin-bottom: 15px; background: var(--surface); }
.generation-side h2 { margin: 0 0 9px; color: var(--muted); font-size: 13px; }
.history-tool-current {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
}
.history-tool-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: none;
  place-items: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.history-tool-icon .icon { width: 18px; height: 18px; }
.history-tool-check {
  width: 16px;
  height: 16px;
  margin-inline-start: auto;
  color: var(--accent-hover);
}
.generation-history {
  display: grid;
  gap: 7px;
  max-block-size: max(124px, calc(100dvh - 200px));
  margin: 0;
  padding: 3px;
  overflow: auto;
  list-style: none;
}
.history-storage-notice {
  margin: 8px 3px 0;
  color: var(--muted);
  font-size: 12px;
}
.history-job {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 60px;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  text-align: left;
}
.history-job:hover { border-color: var(--brand); }
.history-job[aria-current="true"] {
  border-color: var(--brand);
  background: var(--accent-soft);
}
.history-thumb {
  display: grid;
  width: 40px;
  height: 40px;
  flex: none;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: var(--rail);
  color: var(--muted);
}
.history-thumb img { object-fit: cover; }
.history-thumb .generation-spinner { width: 19px; height: 19px; border-width: 2px; }
.history-job-copy { display: grid; min-width: 0; gap: 1px; }
.history-job-copy strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-job-copy > span { color: var(--muted); font-size: 12px; }

.generation-stage {
  display: grid;
  min-width: 0;
  min-height: max(420px, calc(100dvh - 32px));
  place-items: center;
  padding: clamp(14px, 3vw, 42px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.generation-stage:focus { outline: none; }
.generation-progress {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}
.generation-spinner {
  display: block;
  width: 58px;
  height: 58px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: generation-spin 820ms linear infinite;
}
@keyframes generation-spin { to { transform: rotate(1turn); } }
.generation-progress h1, .generation-result h1 {
  margin: 0;
  font-size: clamp(21px, 3vw, 27px);
  letter-spacing: -0.03em;
}
.generation-progress p { margin: 0; color: var(--muted); }
.generation-result {
  display: grid;
  width: min(100%, 760px);
  min-width: 0;
  justify-items: center;
  gap: 18px;
}
.generation-result-heading {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.download-photo { color: var(--accent-hover); text-decoration: none; }
.generation-image {
  display: block;
  width: min(100%, 640px, 66dvh);
  height: auto;
  aspect-ratio: 1;
  border-radius: 10px;
  object-fit: contain;
}

@media (max-width: 760px) {
  .generation-screen { grid-template-columns: minmax(0, 1fr); gap: 9px; padding: 8px; }
  .generation-side { padding: 10px; }
  .generation-back { margin-bottom: 9px; }
  .generation-history { display: flex; max-block-size: none; }
  .generation-history > li { flex: 0 0 min(214px, 82%); }
  .generation-stage { min-height: clamp(410px, 64dvh, 600px); }
  .generation-image { width: min(100%, 510px); }
}

@media (max-width: 820px) {
  .detail-screen { grid-template-columns: minmax(0, 1fr); }
  .detail-preview { min-height: clamp(290px, 78vw, 420px); }
}

@media (max-width: 460px) {
  .detail-screen { gap: 8px; padding: 8px; }
  .detail-back { margin-bottom: 14px; }
  .detail-upload .attach-button { flex: 1 1 100%; }
  #composer .generate { width: 100%; }
}

@media (max-width: 980px) {
  body { grid-template-columns: 188px minmax(0, 1fr); }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .photo-mode-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 438px);
  }
}

@media (max-width: 720px) {
  body { display: block; }
  .sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 15px 14px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { grid-column: 1 / -1; margin: 0 2px 2px; font-size: 24px; }
  .brand-logo { width: 34px; height: 34px; border-radius: 8px; }
  .tools-label { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); }
  .tool { width: fit-content; gap: 5px; min-height: 38px; padding: 0 8px; font-size: 12px; }
  .tool .icon { width: 15px; height: 15px; }
  .history-shortcut { width: auto; min-height: 42px; margin: 0; padding: 4px 8px; font-size: 13px; }
  .history-shortcut-icon { width: 26px; height: 26px; }
  .workspace { padding: 32px 16px 36px; }
  h1 { margin-bottom: 17px; }
  .composer textarea { min-height: 108px; padding: 15px 13px 8px; font-size: 16px; }
  .composer-actions { padding: 8px; }
  .attach-button, .generate { padding: 0 8px; font-size: 12px; }
  .attach-button .icon, .generate .icon { width: 15px; height: 15px; }
  .photo-mode-picker { margin-bottom: 24px; }
  .photo-pill { min-height: 42px; padding-inline: 6px; font-size: 12px; line-height: 1.25; }
  .photo-mode-heading { margin-bottom: 19px; }
  .photo-examples { margin-top: 3px; }
  .photo-examples [role="group"] { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .photo-example { min-height: 43px; }
  .library { margin-top: 28px; }
  .library-heading { padding-top: 18px; }
  .template-grid { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .template { transition: none; }
  .generation-spinner { animation: none; }
}
