:root {
  color-scheme: light;
  --page: #f3f6f4;
  --panel: #ffffff;
  --panel-warm: #fbfaf7;
  --ink: #111827;
  --text: #263241;
  --muted: #6b7280;
  --faint: #9aa4b2;
  --line: #dde4e2;
  --line-strong: #cfd8d6;
  --blue: #315efb;
  --blue-dark: #2447c9;
  --blue-soft: #eef4ff;
  --teal: #0f766e;
  --teal-soft: #e7f6f2;
  --coral: #e76f51;
  --coral-soft: #fff1ec;
  --amber: #bc7a19;
  --amber-soft: #fff7df;
  --green: #15803d;
  --code: #101623;
  --code-top: #182033;
  --code-text: #d9dee8;
  --shadow-sm: 0 8px 22px rgba(17, 24, 39, 0.07);
  --shadow-md: 0 18px 42px rgba(17, 24, 39, 0.1);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(243, 246, 244, 0.94)),
    repeating-linear-gradient(90deg, rgba(15, 118, 110, 0.035) 0 1px, transparent 1px 28px);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  border: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
  letter-spacing: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(520px, 1fr) minmax(400px, 34vw);
  height: 100vh;
  min-height: 760px;
  overflow: hidden;
  padding: 14px;
  gap: 14px;
}

.template-sidebar,
.editor-panel,
.result-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(207, 216, 214, 0.8);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
}

.template-sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.brand-block {
  position: relative;
  padding: 28px 24px 22px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(49, 94, 251, 0.08), transparent 52%),
    linear-gradient(180deg, #ffffff, #fbfaf7);
}

.brand-lockup {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(49, 94, 251, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--blue-soft), #ffffff 70%),
    #fff;
  color: var(--blue);
  box-shadow: 0 10px 24px rgba(49, 94, 251, 0.12);
}

.brand-logo-mark {
  width: 72px;
  height: 72px;
  overflow: hidden;
  background: #fff;
  border-color: rgba(255, 210, 42, 0.72);
  border-radius: 16px;
  box-shadow: 0 14px 34px rgba(255, 210, 42, 0.2);
}

.brand-logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
  padding: 0;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.35;
}

.brand-block .brand-owner {
  margin: 0 0 5px;
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-block h1 {
  color: var(--ink);
  font-size: clamp(1.45rem, 1.75vw, 1.95rem);
  line-height: 1.05;
  font-weight: 900;
}

.brand-block p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.35;
}

.brand-creator {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  margin-top: 18px;
  padding: 10px;
  border: 1px solid rgba(221, 228, 226, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 210, 42, 0.16), rgba(49, 94, 251, 0.04)),
    rgba(255, 255, 255, 0.84);
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.06);
}

.brand-creator img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.14);
}

.brand-creator span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-creator strong {
  display: block;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1.2;
}

.brand-strip {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr;
  gap: 7px;
  margin-top: 18px;
}

.brand-strip span {
  height: 5px;
  border-radius: 999px;
}

.brand-strip span:nth-child(1) {
  background: var(--blue);
}

.brand-strip span:nth-child(2) {
  background: var(--teal);
}

.brand-strip span:nth-child(3) {
  background: var(--coral);
}

.template-list {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 18px;
  scrollbar-color: #b7c0bf transparent;
}

.template-button {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 13px;
  width: 100%;
  min-height: 82px;
  padding: 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.template-button:hover {
  background: #f8fbfa;
  border-color: var(--line);
  transform: translateY(-1px);
}

.template-button.active {
  background:
    linear-gradient(135deg, rgba(49, 94, 251, 0.1), rgba(15, 118, 110, 0.05)),
    #fff;
  border-color: rgba(49, 94, 251, 0.28);
  box-shadow: 0 12px 28px rgba(49, 94, 251, 0.14);
}

.template-button.active::before {
  position: absolute;
  inset: 12px auto 12px 0;
  width: 4px;
  border-radius: 0 999px 999px 0;
  background: var(--blue);
  content: "";
}

.template-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  color: var(--faint);
}

.template-button.active .template-icon {
  background: #ffffff;
  color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(49, 94, 251, 0.16);
}

.template-icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.25;
}

.template-name {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.99rem;
  font-weight: 850;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-desc {
  display: -webkit-box;
  margin-top: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.template-button.active .template-desc {
  color: #2f477c;
}

.editor-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: rgba(251, 250, 247, 0.96);
}

.editor-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 30px 34px 22px;
  border-bottom: 1px solid rgba(221, 228, 226, 0.72);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 45%),
    rgba(255, 255, 255, 0.72);
}

.selected-template {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 16px;
  max-width: 790px;
}

.selected-icon {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.12);
}

.selected-icon svg {
  width: 28px;
  height: 28px;
  stroke-width: 2.35;
}

.selected-template h2 {
  color: var(--ink);
  font-size: clamp(2rem, 3vw, 3.1rem);
  line-height: 1.02;
  font-weight: 900;
}

.selected-template p {
  max-width: 660px;
  margin-top: 12px;
  color: var(--muted);
  font-size: clamp(1rem, 1.24vw, 1.24rem);
  line-height: 1.42;
}

.editor-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding-top: 4px;
}

.icon-button,
.saved-item button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.05);
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.icon-button:hover,
.saved-item button:hover {
  border-color: rgba(49, 94, 251, 0.25);
  background: var(--blue-soft);
  color: var(--blue);
  transform: translateY(-1px);
}

.icon-button svg,
.saved-item button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.25;
}

.editor-scroll {
  overflow: auto;
  padding: 24px 34px 44px;
  scrollbar-color: #b7c0bf transparent;
}

.guide-section,
.form-section,
.assistant-section {
  max-width: 860px;
}

.guide-section,
.form-section {
  margin-bottom: 28px;
}

.guide-section,
.assistant-card {
  border: 1px solid rgba(221, 228, 226, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 18px;
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.06);
}

.section-heading {
  margin-bottom: 16px;
}

.section-kicker {
  margin-bottom: 5px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-heading h2 {
  color: var(--text);
  font-size: 1.06rem;
  font-weight: 860;
}

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

label {
  display: grid;
  gap: 9px;
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 780;
}

.wide-field {
  grid-column: 1 / -1;
}

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

.preset-button,
.quick-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
  font-size: 0.91rem;
  font-weight: 820;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.04);
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.preset-button:hover,
.quick-action:hover {
  border-color: rgba(15, 118, 110, 0.25);
  background: var(--teal-soft);
  color: var(--teal);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.11);
}

.preset-button:nth-child(1):hover,
.preset-button:nth-child(6):hover {
  border-color: rgba(49, 94, 251, 0.25);
  background: var(--blue-soft);
  color: var(--blue);
  box-shadow: 0 12px 24px rgba(49, 94, 251, 0.11);
}

.preset-button:nth-child(4):hover,
.quick-action:nth-child(4):hover {
  border-color: rgba(231, 111, 81, 0.28);
  background: var(--coral-soft);
  color: #b94025;
  box-shadow: 0 12px 24px rgba(231, 111, 81, 0.12);
}

.preset-button svg,
.quick-action svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.3;
}

.custom-style-field[hidden] {
  display: none;
}

input,
textarea,
select {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  outline: 0;
  padding: 15px 16px;
  font-size: 0.98rem;
  line-height: 1.45;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

textarea {
  min-height: 124px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #a7afbc;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 23px) 24px,
    calc(100% - 16px) 24px;
  background-repeat: no-repeat;
  background-size:
    7px 7px,
    7px 7px;
  padding-right: 48px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(49, 94, 251, 0.48);
  background: #fff;
  box-shadow:
    0 0 0 4px rgba(49, 94, 251, 0.11),
    0 12px 24px rgba(17, 24, 39, 0.06);
}

.assistant-section {
  display: grid;
  gap: 16px;
}

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

.layout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.layout-card {
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.layout-card:first-child {
  border-top: 0;
  padding-top: 0;
}

.layout-card:last-child {
  padding-bottom: 0;
}

.layout-card h3 {
  margin-bottom: 5px;
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 860;
}

.layout-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.quality-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.quality-list li {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.quality-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.quality-mark {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 7px;
  background: #dcfce7;
  color: var(--green);
  font-weight: 900;
}

.quality-list strong {
  display: block;
  color: var(--text);
  font-size: 0.9rem;
}

.quality-list span span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.38;
}

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

.saved-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.saved-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.saved-title {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
}

.saved-controls {
  display: flex;
  gap: 6px;
}

.saved-item button {
  width: 34px;
  height: 34px;
  box-shadow: none;
}

.result-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  background:
    linear-gradient(180deg, #ffffff, #fbfaf7);
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 24px 22px;
  border-bottom: 1px solid var(--line);
}

.result-kicker {
  margin-bottom: 6px;
  color: var(--coral);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-toolbar h2 {
  color: var(--ink);
  font-size: clamp(1.35rem, 1.65vw, 1.8rem);
  font-weight: 900;
  line-height: 1.1;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--blue), #2447c9 70%),
    var(--blue);
  color: #fff;
  cursor: pointer;
  padding: 0 18px;
  font-size: 0.96rem;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(49, 94, 251, 0.28);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    filter 0.18s ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  filter: saturate(1.06);
  box-shadow: 0 18px 36px rgba(49, 94, 251, 0.34);
}

.primary-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.25;
}

.prompt-stage {
  overflow: auto;
  padding: 24px;
  scrollbar-color: #5c6678 transparent;
}

#promptOutput {
  position: relative;
  min-height: min(720px, calc(100vh - 214px));
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(180deg, var(--code-top), var(--code)),
    var(--code);
  color: var(--code-text);
  padding: 32px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: clamp(0.86rem, 0.98vw, 1.02rem);
  line-height: 1.68;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 20px 42px rgba(16, 22, 35, 0.24);
}

.prompt-note {
  padding: 16px 24px 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.author-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  margin: 0 24px 24px;
  padding: 12px;
  border: 1px solid rgba(221, 228, 226, 0.9);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 210, 42, 0.16), transparent 48%),
    #fff;
  box-shadow: 0 12px 26px rgba(17, 24, 39, 0.06);
}

.author-card img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.14);
}

.author-card p {
  margin-bottom: 3px;
  color: var(--amber);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.author-card strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.1;
}

.author-card span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.hidden-panels {
  display: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: min(380px, calc(100vw - 48px));
  padding: 12px 15px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

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

@media (max-width: 1320px) {
  .app-shell {
    grid-template-columns: 280px minmax(400px, 1fr) 380px;
  }

  .editor-topbar,
  .editor-scroll {
    padding-left: 24px;
    padding-right: 24px;
  }

  .selected-template h2 {
    font-size: 2.15rem;
  }

  .form-grid,
  .quick-actions,
  .preset-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    grid-template-columns: 1fr;
  }

  .template-sidebar,
  .editor-panel,
  .result-panel {
    overflow: visible;
  }

  .template-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
  }

  .editor-scroll,
  .prompt-stage {
    overflow: visible;
  }

  .result-panel {
    grid-template-rows: auto auto auto;
  }

  #promptOutput {
    min-height: 420px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  .brand-block,
  .editor-topbar,
  .editor-scroll,
  .result-toolbar,
  .prompt-stage,
  .prompt-note {
    padding-left: 16px;
    padding-right: 16px;
  }

  .brand-lockup,
  .selected-template {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .selected-icon {
    width: 40px;
    height: 40px;
  }

  .brand-mark {
    width: 56px;
    height: 56px;
  }

  .brand-logo-mark {
    width: 56px;
    height: 56px;
    border-radius: 12px;
  }

  .template-list {
    grid-template-columns: 1fr;
    padding-left: 12px;
    padding-right: 12px;
  }

  .editor-topbar,
  .result-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .editor-actions {
    justify-content: flex-end;
  }

  .selected-template h2 {
    font-size: 1.8rem;
  }

  #promptOutput {
    padding: 22px;
  }
}
