@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,500;0,600;0,700;1,500&family=Manrope:wght@400;500;600;700;800&display=swap');

:root{
  --ink:#1B2430;
  --cream:#FAF7F2;
  --amber:#E2A63B;
  --coral:#DB5B3C;
  --slate:#5B6572;
  --line:#E4DFD3;
  --card:#FFFFFF;
  --ok:#3E8E5A;
}
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  background:var(--cream);
  color:var(--ink);
  font-family:'Manrope', sans-serif;
  line-height:1.5;
}
h1,h2,h3{ font-family:'Fraunces', serif; margin:0; color:var(--ink); }
a{ color:var(--coral); }

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 24px; border-bottom:1px solid var(--line); background:var(--card);
  flex-wrap:wrap; gap:10px;
}
.brandmark{ font-family:'Fraunces', serif; font-weight:600; font-size:19px; }
.brandmark span{ color:var(--coral); }
.topbar-right{ display:flex; align-items:center; gap:14px; font-size:14px; color:var(--slate); flex-wrap:wrap; }

.btn{
  border:none; border-radius:5px; padding:12px 18px; font-family:'Manrope';
  font-weight:700; font-size:14.5px; cursor:pointer; min-height:44px;
  display:inline-flex; align-items:center; justify-content:center; text-decoration:none;
}
.btn-primary{ background:var(--coral); color:#fff; }
.btn-primary:hover{ background:#C34E33; }
.btn-ghost{ background:transparent; color:var(--ink); border:1px solid var(--line); }
.btn-ghost:hover{ background:#F1ECE1; }
.btn-sm{ padding:9px 14px; font-size:13px; min-height:38px; }
.btn-block{ width:100%; }

main{ max-width:1000px; margin:0 auto; padding:28px 20px 80px; }
.page-head{ display:flex; align-items:baseline; justify-content:space-between; margin-bottom:20px; flex-wrap:wrap; gap:10px; }
.page-head h1{ font-size:26px; }

label{ display:block; font-size:13px; font-weight:700; margin:14px 0 6px; color:var(--ink); }
input, select, textarea{
  width:100%; padding:12px; border:1px solid var(--line); border-radius:5px;
  font-family:'Manrope'; font-size:15px; background:#fff; color:var(--ink);
}
textarea{ resize:vertical; min-height:80px; }
.error-msg{ color:var(--coral); font-size:13px; margin-top:8px; min-height:16px; }
.status-msg{ font-size:13px; margin-top:8px; min-height:16px; color:var(--slate); }

.auth-wrap{
  max-width:400px; margin:8vh auto 0; padding:32px 26px;
  background:var(--card); border:1px solid var(--line); border-radius:8px;
}
.auth-wrap h1{ font-size:25px; margin-bottom:6px; }
.auth-wrap p.sub{ color:var(--slate); font-size:14px; margin:0 0 20px; }
.auth-toggle{ margin-top:16px; font-size:13.5px; color:var(--slate); text-align:center; }
.auth-note{ margin-top:18px; font-size:12px; color:#8A8375; border-top:1px solid var(--line); padding-top:12px; }

.grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(200px,1fr)); gap:16px; }
.card-link{ text-decoration:none; color:inherit; }
.brand-card{
  background:var(--card); border:1px solid var(--line); border-radius:8px; padding:18px;
}
.brand-card:hover{ border-color:var(--amber); }
.brand-card .logo-wrap{ width:100%; height:60px; display:flex; align-items:center; margin-bottom:12px; }
.brand-card img{ max-height:56px; max-width:100%; object-fit:contain; }
.logo-fallback{
  width:52px; height:52px; border-radius:6px; background:var(--amber); color:#fff;
  display:flex; align-items:center; justify-content:center; font-family:'Fraunces'; font-weight:600; font-size:19px;
}
.brand-card h3{ font-size:16.5px; margin-bottom:4px; }
.badge{
  display:inline-block; font-size:11.5px; font-weight:700; color:var(--slate);
  background:#F1ECE1; padding:3px 9px; border-radius:20px; margin-top:4px;
}
.add-tile{
  border:1.5px dashed var(--line); border-radius:8px; display:flex; align-items:center; justify-content:center;
  min-height:130px; color:var(--slate); font-weight:700; font-size:14px; text-decoration:none;
}
.add-tile:hover{ border-color:var(--coral); color:var(--coral); }

.back-link{ font-size:13.5px; color:var(--slate); text-decoration:none; margin-bottom:16px; display:inline-block; }
.back-link:hover{ color:var(--coral); }
.brand-header{ display:flex; align-items:center; gap:16px; margin-bottom:24px; flex-wrap:wrap; }
.brand-header .logo-wrap{ width:64px; height:64px; border:1px solid var(--line); border-radius:8px; display:flex; align-items:center; justify-content:center; background:#fff; overflow:hidden; flex-shrink:0; }
.brand-header img{ max-width:90%; max-height:90%; object-fit:contain; }

.panel{ background:var(--card); border:1px solid var(--line); border-radius:8px; padding:20px; margin-bottom:20px; }

.mode-row{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:16px; }
.mode-pill{
  padding:10px 16px; border-radius:20px; border:1px solid var(--line); background:#fff; cursor:pointer;
  font-size:13.5px; font-weight:700; color:var(--slate); min-height:40px;
}
.mode-pill.active{ background:var(--ink); color:#fff; border-color:var(--ink); }
.mode-section{ display:none; }
.mode-section.active{ display:block; }

.festival-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(150px,1fr)); gap:10px; margin-top:6px; }
.fest-label{
  border:1px solid var(--line); border-left:4px solid var(--fc,var(--coral)); border-radius:5px; padding:12px;
  cursor:pointer; font-size:13.5px; background:#fff; display:block;
}
.fest-label input{ display:none; }
.fest-label.active{ box-shadow:0 0 0 1px var(--fc,var(--coral)) inset; }
.fest-label .g{ font-size:18px; display:block; margin-bottom:4px; }
.fest-label b{ display:block; font-size:14px; }

.output-card{ background:var(--ink); color:#F3EFE4; border-radius:8px; padding:22px; margin-top:8px; }
.output-head{ display:flex; justify-content:space-between; align-items:baseline; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.output-head h2{ font-size:18px; color:#fff; }
#prompt-text{
  background:#0F1620; border:1px solid #33404F; border-radius:6px; padding:16px; font-size:13.3px;
  white-space:pre-wrap; line-height:1.6; max-height:400px; overflow-y:auto; color:#DCE3EA;
}

.history-item{
  border:1px solid var(--line); border-radius:6px; padding:14px 16px; margin-bottom:10px; background:#fff;
  display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap;
}
.history-item .h-meta{ font-size:13px; color:var(--slate); }
.history-item .h-title{ font-weight:700; font-size:14.5px; }
.history-actions{ display:flex; gap:8px; flex-wrap:wrap; }
.empty-note{ color:var(--slate); font-size:14px; padding:8px 0; }

.logo-upload-row{ display:flex; align-items:center; gap:14px; margin-top:8px; flex-wrap:wrap; }
.logo-preview{
  width:60px; height:60px; border-radius:6px; border:1px solid var(--line); background:#F1ECE1;
  display:flex; align-items:center; justify-content:center; overflow:hidden; flex-shrink:0; font-size:12px; color:var(--slate);
}
.logo-preview img{ max-width:100%; max-height:100%; object-fit:contain; }

.autofill-row{ display:flex; gap:8px; flex-wrap:wrap; }
.autofill-row input{ flex:1; min-width:180px; }

.form-actions{ display:flex; gap:10px; margin-top:22px; flex-wrap:wrap; }

.swatch-row{ display:flex; gap:12px; flex-wrap:wrap; margin-top:8px; margin-bottom:18px; }
.swatch-card{
  border:1px solid var(--line); border-radius:8px; padding:10px; cursor:pointer; text-align:center;
  width:110px; background:#fff;
}
.swatch-card input{ display:none; }
.swatch-card.active{ border-color:var(--coral); box-shadow:0 0 0 1px var(--coral) inset; }
.swatch-card b{ display:block; font-size:11.5px; margin-top:8px; color:var(--slate); font-weight:700; }
.swatch-preview{
  position:relative; display:block; width:100%; height:64px; border-radius:5px;
  background:linear-gradient(180deg, #F7F1E4 0%, #EFE6D3 100%); overflow:hidden;
}
.sw-logo{ position:absolute; top:5px; left:5px; width:14px; height:10px; background:#fff; border:1px solid var(--line); border-radius:2px; }
.sw-bar{ position:absolute; left:0; right:0; height:11px; }
.sw-bar-1{ bottom:11px; background:var(--coral); }
.sw-bar-2{ bottom:0; background:var(--ink); }
.sw-card{ position:absolute; bottom:6px; left:8px; right:8px; height:22px; background:#fff; border:1px solid var(--line); border-radius:6px; box-shadow:0 2px 4px rgba(0,0,0,0.12); }
.sw-ribbon{ position:absolute; bottom:14px; left:-14px; width:44px; height:16px; background:var(--amber); transform:rotate(-35deg); }
.sw-strip{ position:absolute; bottom:0; left:0; right:0; height:7px; background:var(--ink); }
.sw-line{ position:absolute; bottom:6px; left:8px; right:8px; height:6px; background:var(--ink); border-radius:3px; }

.chip-row{ display:flex; gap:8px; flex-wrap:wrap; margin:6px 0 16px; }
.chip{
  border:1px solid var(--line); background:#fff; border-radius:20px; padding:8px 14px;
  font-size:13px; font-weight:600; color:var(--ink); cursor:pointer;
}
.chip:hover{ border-color:var(--coral); }
.chip-date{ color:var(--slate); font-weight:400; margin-left:4px; }
.category-row{ display:flex; gap:6px; flex-wrap:wrap; margin:8px 0 10px; }
.cat-chip{ font-size:12px; padding:6px 12px; }
.cat-chip.active{ background:var(--ink); color:#fff; border-color:var(--ink); }

.event-list{
  max-height:280px; overflow-y:auto; border:1px solid var(--line); border-radius:6px;
  padding:6px; display:flex; flex-direction:column; gap:2px;
}
.event-row{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:9px 10px; border-radius:5px; cursor:pointer; border-left:3px solid transparent;
  font-size:13.5px;
}
.event-row:hover{ background:#F7F2E7; }
.event-row.active{ background:#F1ECE1; border-left-color:var(--fc, var(--coral)); font-weight:700; }
.event-row input{ display:none; }
.event-cat{ font-size:11px; color:var(--slate); white-space:nowrap; }

.sw-diagonal{ position:absolute; bottom:0; left:0; right:0; height:26px; background:var(--ink); clip-path:polygon(0 40%, 100% 0, 100% 100%, 0% 100%); }
.sw-wave{ position:absolute; bottom:0; left:0; right:0; height:24px; background:var(--coral); border-radius:50% 50% 0 0 / 100% 100% 0 0; }
.sw-arch{ position:absolute; bottom:6px; left:50%; transform:translateX(-50%); width:46px; height:18px; background:var(--ink); border-radius:20px 20px 4px 4px; }
.sw-grid{ position:absolute; bottom:5px; width:16px; height:14px; background:#fff; border:1px solid var(--line); border-radius:2px; }
.sw-icons{ position:absolute; bottom:16px; left:10px; right:10px; height:8px; background:repeating-linear-gradient(90deg, var(--coral) 0 6px, transparent 6px 12px); border-radius:2px; }
.sw-thinline{ position:absolute; bottom:4px; left:14px; right:14px; height:5px; background:var(--ink); border-radius:3px; }
.sw-sidepanel{ position:absolute; top:0; bottom:0; right:0; width:20px; background:var(--ink); }
.sw-badge{ position:absolute; bottom:6px; right:8px; width:18px; height:18px; border-radius:50%; background:var(--amber); }
.sw-frame{ position:absolute; inset:4px; border:3px solid var(--ink); border-radius:4px; }
.sw-split-a{ position:absolute; bottom:0; left:0; width:50%; height:22px; background:var(--coral); }
.sw-split-b{ position:absolute; bottom:0; right:0; width:50%; height:22px; background:var(--ink); }
.sw-pill{ position:absolute; bottom:6px; width:20px; height:10px; background:var(--ink); border-radius:8px; }
.sw-rule{ position:absolute; left:10px; right:10px; height:2px; background:var(--ink); }
.sw-sticker{ position:absolute; bottom:2px; right:2px; width:26px; height:26px; border-radius:50%; background:var(--coral); transform:rotate(-15deg); border:2px dashed rgba(255,255,255,0.6); }

.event-icon{ font-size:15px; margin-right:2px; }
.batch-bar{ display:flex; align-items:center; justify-content:space-between; gap:10px; background:#F1ECE1; border-radius:6px; padding:10px 14px; margin:10px 0; flex-wrap:wrap; }
.batch-bar span{ font-size:13px; font-weight:700; }
.template-row{ display:flex; gap:8px; flex-wrap:wrap; margin:8px 0 16px; }
.template-chip{ padding:7px 13px; border-radius:16px; border:1px solid var(--line); background:#fff; font-size:12.5px; cursor:pointer; font-weight:600; }
.template-chip:hover{ border-color:var(--coral); }
.result-card{ border:1px solid var(--line); border-radius:6px; padding:14px; margin-bottom:10px; background:#fff; }
.result-card .rc-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; gap:8px; flex-wrap:wrap; }
.result-card .rc-head b{ font-size:14px; }
.result-card pre{ white-space:pre-wrap; font-size:12px; background:#F7F2E7; padding:10px; border-radius:5px; max-height:220px; overflow-y:auto; margin:0; font-family:'Manrope',monospace; }
.history-filter{ display:flex; gap:6px; }
.history-filter .active{ background:var(--ink); color:#fff; border-color:var(--ink); }

.theme-gallery{ display:grid; grid-template-columns:repeat(auto-fill, minmax(120px,1fr)); gap:12px; margin:10px 0 18px; }
.theme-card{ cursor:pointer; display:block; }
.theme-card input{ display:none; }
.mini-poster{ position:relative; width:100%; aspect-ratio:3/4; border-radius:8px; overflow:hidden; border:2px solid transparent; box-shadow:0 1px 4px rgba(0,0,0,0.15); }
.theme-card.active .mini-poster{ border-color:var(--coral); }
.mp-texture{ position:absolute; inset:0; }
.mp-headline{ position:absolute; top:14%; left:0; right:0; text-align:center; font-size:12px; line-height:1.2; }
.mp-footer{ position:absolute; bottom:0; left:0; right:0; height:26%; }
.mp-bar{ position:absolute; left:0; right:0; height:38%; }
.mp-bar1{ bottom:38%; background:rgba(255,255,255,0.25); }
.mp-bar2{ bottom:0; background:rgba(0,0,0,0.35); }
.mp-card2{ position:absolute; bottom:10%; left:10%; right:10%; height:55%; background:rgba(255,255,255,0.85); border-radius:6px; }
.theme-label{ font-size:10.5px; color:var(--slate); margin-top:5px; text-align:center; line-height:1.25; }

/* ---------- Tablet ---------- */
@media (max-width: 900px){
  main{ padding:22px 16px 70px; }
  .auth-wrap{ margin-top:6vh; }
}

/* ---------- Mobile ---------- */
@media (max-width: 560px){
  .topbar{ padding:14px 16px; }
  .brandmark{ font-size:17px; }
  main{ padding:18px 14px 60px; }
  .page-head h1{ font-size:22px; }
  .grid{ grid-template-columns:1fr 1fr; gap:12px; }
  .brand-header{ gap:12px; }
  .mode-pill{ flex:1 1 auto; text-align:center; }
  .form-actions{ flex-direction:column; }
  .form-actions .btn{ width:100%; }
  .history-item{ flex-direction:column; align-items:flex-start; }
}

@media (max-width: 360px){
  .grid{ grid-template-columns:1fr; }
}
