/* ============================================================
   AGE YT# Penghasil Prompt — Gold Luxury Theme
   ============================================================ */

:root {
  --bg-void: #0a0806;
  --bg-panel: #14100a;
  --bg-panel-raised: #1d160d;
  --bg-input: #100c07;

  --gold-300: #f0d27a;
  --gold-500: #c9a227;
  --gold-600: #a5811b;
  --gold-700: #6e5512;

  --ivory: #f4ecd8;
  --ivory-dim: #a89a7a;
  --ivory-faint: #6e6350;

  --wine: #5c1418;
  --wine-bright: #8f2027;

  --success: #6fa66a;
  --danger: #c2564f;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;

  --shadow-deep: 0 20px 50px -20px rgba(0,0,0,0.7);
}

* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; }

/* PENTING: pastikan atribut hidden SELALU menang atas display apapun yang
   diset class lain (mis. .modal-overlay{display:flex} atau .field-row{display:grid}).
   Tanpa ini, elemen yang di-hidden via JS bisa tetap terlihat karena CSS
   penulis (author stylesheet) lebih diprioritaskan daripada default browser
   untuk atribut [hidden]. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 900px 500px at 15% -5%, rgba(201,162,39,0.08), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(201,162,39,0.05), transparent 55%),
    var(--bg-void);
  color: var(--ivory);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold-600); color: #14100a; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-panel); }
::-webkit-scrollbar-thumb { background: var(--gold-700); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-600); }

.grain-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  opacity: 0.035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button, input, select, textarea { font-family: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold-300); outline-offset: 2px; }

/* ---------------- TOPBAR ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px 28px;
  border-bottom: 1px solid rgba(201,162,39,0.22);
  background: linear-gradient(180deg, rgba(20,16,10,0.9), rgba(20,16,10,0.6));
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 50;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.seal { color: var(--gold-500); width: 42px; height: 42px; flex-shrink: 0; filter: drop-shadow(0 0 6px rgba(201,162,39,0.35)); }
.seal svg { width: 100%; height: 100%; }
.brand-eyebrow {
  margin: 0; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--gold-500); font-weight: 700;
}
.brand-text h1 {
  margin: 2px 0 0; font-family: var(--font-display); font-weight: 900;
  font-size: 24px; letter-spacing: 0.01em; color: var(--ivory);
}
.topbar-actions { display: flex; gap: 10px; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid rgba(201,162,39,0.35);
  color: var(--ivory-dim); padding: 10px 16px; border-radius: 999px;
  font-weight: 600; font-size: 14px; cursor: pointer; transition: all .18s ease;
}
.btn-ghost:hover { border-color: var(--gold-500); color: var(--gold-300); }
.btn-ghost.small { padding: 6px 12px; font-size: 12.5px; }
.btn-ghost.danger:hover { border-color: var(--danger); color: var(--danger); }

.btn-gold {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--gold-300), var(--gold-600));
  color: #16120a; border: none; padding: 10px 18px; border-radius: 999px;
  font-weight: 800; font-size: 14px; cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(201,162,39,0.6);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 10px 26px -8px rgba(201,162,39,0.8); }

/* ---------------- LAYOUT ---------------- */
.layout {
  display: grid; grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px; padding: 28px; max-width: 1400px; margin: 0 auto;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; gap: 18px; }
}

.panel {
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-panel-raised));
  border: 1px solid rgba(201,162,39,0.18);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-deep);
  position: sticky; top: 96px;
}
.panel-output { position: static; }

/* ornamental corner frame */
.frame-corners {
  position: relative; padding: 26px;
}
.frame-corners::before, .frame-corners::after {
  content: ''; position: absolute; width: 22px; height: 22px;
  border-color: var(--gold-500); opacity: 0.65; pointer-events: none;
}
.frame-corners::before {
  top: 10px; left: 10px; border-top: 2px solid; border-left: 2px solid;
}
.frame-corners::after {
  bottom: 10px; right: 10px; border-bottom: 2px solid; border-right: 2px solid;
}

/* ---------------- MODE SWITCH ---------------- */
.mode-switch {
  display: flex; background: var(--bg-input); border-radius: 999px;
  padding: 4px; margin-bottom: 20px; border: 1px solid rgba(201,162,39,0.15);
}
.mode-btn {
  flex: 1; background: transparent; border: none; color: var(--ivory-dim);
  padding: 10px 12px; border-radius: 999px; font-weight: 700; font-size: 13px;
  cursor: pointer; transition: all .18s ease;
}
.mode-btn.active { background: linear-gradient(135deg, var(--gold-300), var(--gold-600)); color: #16120a; }

/* ---------------- FIELDS ---------------- */
.field-label {
  display: block; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--gold-500); font-weight: 700; margin: 16px 0 8px;
}
.field-label:first-child { margin-top: 0; }

.field-textarea, .field-input, .field-select {
  width: 100%; background: var(--bg-input); border: 1px solid rgba(201,162,39,0.25);
  color: var(--ivory); border-radius: var(--radius-md); padding: 12px 14px;
  font-size: 14.5px; font-family: var(--font-body); resize: vertical;
  transition: border-color .15s ease;
}
.field-textarea:focus, .field-input:focus, .field-select:focus { border-color: var(--gold-500); }
.field-select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath fill='%23c9a227' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }
.field-col { min-width: 0; }

.checkbox-row {
  display: flex; align-items: center; gap: 10px; margin-top: 18px;
  font-size: 13.5px; color: var(--ivory-dim); cursor: pointer; user-select: none;
}
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--gold-500); }

/* pill group */
.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  background: var(--bg-input); border: 1px solid rgba(201,162,39,0.25); color: var(--ivory-dim);
  padding: 9px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all .15s ease;
}
.pill.active { background: linear-gradient(135deg, var(--gold-300), var(--gold-600)); color: #16120a; border-color: transparent; }

/* ---------------- GENERATE BUTTON ---------------- */
.btn-generate {
  position: relative; overflow: hidden; width: 100%; margin-top: 22px;
  background: linear-gradient(135deg, var(--gold-300), var(--gold-600) 60%, var(--gold-700));
  color: #16120a; border: none; padding: 16px; border-radius: var(--radius-md);
  font-family: var(--font-display); font-weight: 900; font-size: 17px; letter-spacing: 0.02em;
  cursor: pointer; box-shadow: 0 12px 30px -12px rgba(201,162,39,0.7);
  transition: transform .15s ease;
}
.btn-generate:hover { transform: translateY(-1px); }
.btn-generate:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-generate-shine {
  position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,0.55), transparent);
  transform: skewX(-20deg); animation: shine 3.2s ease-in-out infinite;
}
@keyframes shine { 0% { left: -60%; } 45%, 100% { left: 130%; } }
@media (prefers-reduced-motion: reduce) { .btn-generate-shine { animation: none; display:none; } }

.provider-status { font-size: 12.5px; color: var(--ivory-faint); margin: 12px 0 0; text-align: center; }
.provider-status b { color: var(--gold-500); }

/* ---------------- OUTPUT ---------------- */
.output-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 26px 0;
}
.output-header h2 { font-family: var(--font-display); font-size: 20px; margin: 0; color: var(--gold-300); }
.result-feed { padding: 18px 26px 26px; display: flex; flex-direction: column; gap: 18px; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 60px 20px; color: var(--ivory-faint); text-align: center;
}

/* result card */
.result-card {
  background: var(--bg-panel-raised); border: 1px solid rgba(201,162,39,0.2);
  border-radius: var(--radius-lg); padding: 20px; position: relative;
  animation: rise .35s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.result-card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.result-card-head h3 {
  font-family: var(--font-display); font-size: 18px; margin: 0; color: var(--ivory); max-width: 70%;
}
.result-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
  padding: 4px 9px; border-radius: 999px; border: 1px solid rgba(201,162,39,0.35); color: var(--gold-300);
  white-space: nowrap;
}

.variant-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.variant-tab {
  background: var(--bg-input); border: 1px solid rgba(201,162,39,0.2); color: var(--ivory-dim);
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.variant-tab.active { background: var(--gold-600); color: #16120a; border-color: transparent; }

.prompt-block { margin-bottom: 14px; }
.prompt-block-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700;
  color: var(--gold-500); margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between;
}
.prompt-text {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.65; color: var(--ivory);
  background: var(--bg-input); border: 1px solid rgba(201,162,39,0.15); border-radius: var(--radius-sm);
  padding: 12px 14px; white-space: pre-wrap; word-break: break-word;
}
.prompt-text.id-translation { color: var(--ivory-dim); font-family: var(--font-body); font-style: italic; }
.prompt-text.negative { color: #d99a96; }

.copy-btn {
  background: none; border: none; color: var(--gold-500); font-size: 11px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.copy-btn:hover { color: var(--gold-300); }

.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.chip-btn {
  background: transparent; border: 1px solid rgba(201,162,39,0.3); color: var(--ivory-dim);
  padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.chip-btn:hover { border-color: var(--gold-500); color: var(--gold-300); }

/* ---------------- MODAL ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6,4,2,0.72); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal {
  width: 100%; max-width: 620px; max-height: 84vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-panel-raised));
  border: 1px solid rgba(201,162,39,0.3); border-radius: var(--radius-lg);
  padding: 26px; box-shadow: var(--shadow-deep);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h2 { font-family: var(--font-display); font-size: 22px; color: var(--gold-300); margin: 0; }
.modal-close {
  background: none; border: none; color: var(--ivory-dim); font-size: 18px; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
}
.modal-close:hover { color: var(--gold-300); background: rgba(201,162,39,0.1); }
.modal-sub { color: var(--ivory-faint); font-size: 13px; line-height: 1.6; margin: 8px 0 20px; }
.modal-sub-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-sub-row .modal-sub { margin: 0 0 14px; }

/* provider cards inside key modal */
.provider-card {
  border: 1px solid rgba(201,162,39,0.18); border-radius: var(--radius-md);
  padding: 16px; margin-bottom: 14px; background: var(--bg-panel);
}
.provider-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.provider-card-head h3 { font-family: var(--font-display); font-size: 16px; margin: 0; color: var(--ivory); }
.provider-link { font-size: 12px; color: var(--gold-500); text-decoration: none; }
.provider-link:hover { color: var(--gold-300); text-decoration: underline; }
.provider-note { font-size: 12px; color: var(--ivory-faint); margin: 8px 0 12px; line-height: 1.55; }
.provider-note b { color: var(--ivory-dim); }

.key-row { display: flex; gap: 8px; margin-bottom: 8px; }
.key-row input {
  flex: 1; background: var(--bg-input); border: 1px solid rgba(201,162,39,0.25);
  color: var(--ivory); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px;
  font-family: var(--font-mono);
}
.key-row button {
  background: rgba(201,162,39,0.12); border: 1px solid rgba(201,162,39,0.3); color: var(--gold-300);
  border-radius: var(--radius-sm); padding: 0 12px; cursor: pointer; font-size: 12px; font-weight: 700;
}
.key-row button:hover { background: rgba(201,162,39,0.22); }
.key-row.saved input { color: var(--ivory-dim); }
.key-row .remove-key { color: var(--danger); border-color: rgba(194,86,79,0.35); background: rgba(194,86,79,0.08); }

.add-key-btn {
  width: 100%; background: transparent; border: 1px dashed rgba(201,162,39,0.35); color: var(--gold-500);
  border-radius: var(--radius-sm); padding: 9px; font-size: 12.5px; font-weight: 700; cursor: pointer; margin-top: 4px;
}
.add-key-btn:hover { border-style: solid; }

/* history */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  border: 1px solid rgba(201,162,39,0.18); border-radius: var(--radius-sm); padding: 12px 14px;
  cursor: pointer; transition: border-color .15s ease;
}
.history-item:hover { border-color: var(--gold-500); }
.history-item-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.history-item h4 { margin: 0; font-size: 14px; font-family: var(--font-display); color: var(--ivory); }
.history-item time { font-size: 11px; color: var(--ivory-faint); }
.history-item p { margin: 6px 0 0; font-size: 12.5px; color: var(--ivory-dim); font-family: var(--font-mono); }
.history-empty { color: var(--ivory-faint); font-size: 13px; text-align: center; padding: 30px 0; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--gold-300), var(--gold-600)); color: #16120a;
  padding: 12px 22px; border-radius: 999px; font-weight: 700; font-size: 13.5px;
  box-shadow: var(--shadow-deep); z-index: 300; animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* spinner */
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .topbar { padding: 14px 16px; }
  .brand-text h1 { font-size: 19px; }
  .output-header { padding: 18px 18px 0; }
  .result-feed { padding: 14px 18px 20px; }
}

/* HP kecil (Android budget, iPhone SE, dsb — lebar layar ~360-400px) */
@media (max-width: 400px) {
  .topbar { padding: 12px; gap: 10px; }
  .brand { gap: 8px; }
  .seal { width: 34px; height: 34px; }
  .brand-eyebrow { font-size: 10px; }
  .brand-text h1 { font-size: 16px; }
  .topbar-actions { gap: 6px; width: 100%; }
  .btn-ghost, .btn-gold { padding: 8px 12px; font-size: 12.5px; flex: 1; justify-content: center; }

  .layout { padding: 12px; gap: 12px; }
  .frame-corners { padding: 16px; }
  .frame-corners::before, .frame-corners::after { width: 14px; height: 14px; }

  .field-textarea, .field-input, .field-select { padding: 10px 12px; font-size: 14px; }
  .field-select { padding-right: 30px; }
  .pill { padding: 8px 11px; font-size: 12.5px; }
  .mode-btn { font-size: 12px; padding: 9px 8px; }

  .btn-generate { font-size: 15px; padding: 14px; }

  .output-header { padding: 14px 14px 0; }
  .output-header h2 { font-size: 17px; }
  .result-feed { padding: 10px 14px 16px; gap: 14px; }
  .result-card { padding: 14px; }
  .result-card-head h3 { font-size: 16px; max-width: 100%; }
  .prompt-text { font-size: 12px; padding: 10px 12px; }

  .modal { padding: 18px; max-height: 88vh; }
  .modal-head h2 { font-size: 19px; }
  .provider-card { padding: 12px; }
  .key-row { flex-wrap: wrap; }
  .key-row input { font-size: 12px; min-width: 0; }
  .key-row button { padding: 8px 10px; font-size: 11px; }
}
