/* ═══════════════════════════════════════
   PAGES.CSS — Page-specific styles
   (Consoles, Templates, Library, Stats…)
   ═══════════════════════════════════════ */

/* ── CONSOLES PAGE ── */
.prompt-area {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 8px; overflow: hidden; margin-bottom: 12px;
  transition: border-color .2s;
}
.prompt-area:focus-within { border-color: var(--ink); }

#promptInput {
  width: 100%; background: transparent; border: none; outline: none;
  font-family: 'IBM Plex Mono', monospace; font-size: 13px; line-height: 1.8;
  color: var(--ink); resize: none; min-height: 110px; padding: 15px 17px;
}
#promptInput::placeholder { color: var(--muted2); }

.prompt-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 13px; border-top: 1px solid var(--border);
  background: var(--bg2); flex-wrap: wrap; gap: 7px;
}
.pbar-l { font-size: 10px; color: var(--muted); display: flex; gap: 12px; }
.pbar-r { display: flex; gap: 5px; }

.action-row { display: flex; align-items: center; gap: 7px; margin-bottom: 16px; flex-wrap: wrap; }

/* AI SUGGEST PANEL */
.suggest-panel {
  background: var(--yellow-bg); border: 1.5px solid #e8d080;
  border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; display: none;
}
.suggest-panel.open { display: block; }
.suggest-panel-title { font-size: 10px; letter-spacing: .15em; text-transform: uppercase; color: var(--yellow); margin-bottom: 10px; font-weight: 600; }
.suggest-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.suggest-chip {
  display: flex; align-items: center; gap: 7px;
  background: #fff8e0; border: 1.5px solid #e8d080; border-radius: 6px;
  padding: 7px 12px; cursor: pointer; transition: all .15s; font-size: 11px; color: var(--ink);
}
.suggest-chip strong { color: var(--ink); }
.suggest-chip-reason { font-size: 9px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-left: 4px; }
.suggest-chip:hover { background: var(--yellow); color: #fff; border-color: var(--yellow); }
.suggest-chip:hover strong,
.suggest-chip:hover .suggest-chip-reason { color: #fff; }

/* AI GRID */
.ai-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 2px; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden;
}
.ai-card {
  background: var(--card-bg); padding: 17px 15px 24px;
  cursor: pointer; position: relative; transition: background .15s;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  animation: cardIn .4s ease both;
}
@keyframes cardIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.ai-card:hover  { background: var(--card-hover); }
.ai-card.pinned { border-top: 3px solid #c0940a; }

.card-top   { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.card-icon  { width: 32px; height: 32px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 16px; border: 1px solid var(--border); flex-shrink: 0; background: var(--bg2); }
.card-badge { font-size: 8px; letter-spacing: .08em; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; }
.badge-free     { background: var(--green-bg);  color: var(--green); }
.badge-freemium { background: var(--yellow-bg); color: var(--yellow); }
.badge-custom   { background: var(--purple-bg); color: var(--purple); }

.card-name  { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 14px; color: var(--ink); margin-bottom: 2px; line-height: 1.1; }
.card-sub   { font-size: 9px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.card-note  { font-size: 10px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.card-usage { position: absolute; bottom: 10px; left: 14px; font-size: 9px; color: var(--muted2); }
.card-bar   { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; }
.card-pin   { position: absolute; top: 9px; right: 9px; background: transparent; border: none; font-size: 13px; opacity: .35; transition: opacity .15s; padding: 2px; cursor: pointer; }
.ai-card:hover .card-pin { opacity: .8; }
.card-pin.on { opacity: 1; }
.card-arrow { position: absolute; bottom: 10px; right: 11px; font-size: 12px; color: var(--border2); transition: all .18s; }
.ai-card:hover .card-arrow { color: var(--ink); transform: translate(2px,-2px); }

/* PINNED ROW */
.pinned-section { margin-bottom: 18px; }
.pin-row { display: flex; gap: 7px; flex-wrap: wrap; }
.pin-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--yellow-bg); border: 1.5px solid #e8d080; border-radius: 6px;
  padding: 6px 11px; cursor: pointer; transition: all .15s; font-size: 11px; color: var(--yellow);
}
.pin-chip:hover { background: var(--yellow); color: #fff; border-color: var(--yellow); }

/* OPEN ALL BAR */
.open-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 8px;
  margin-top: 14px; flex-wrap: wrap;
}
.btn-open-all {
  background: var(--ink); color: var(--bg);
  font-family: 'Bebas Neue', sans-serif; font-size: 17px; letter-spacing: .07em;
  padding: 9px 22px; border-radius: 6px; white-space: nowrap;
}
.btn-open-all:hover { opacity: .88; transform: translateY(-1px); }
.btn-open-fav {
  background: var(--yellow-bg); color: var(--yellow);
  border: 1.5px solid #e8d080; font-family: 'Bebas Neue', sans-serif;
  font-size: 15px; letter-spacing: .06em; padding: 9px 16px; border-radius: 6px; white-space: nowrap;
}
.btn-open-fav:hover { background: var(--yellow); color: #fff; border-color: var(--yellow); }
.open-note { font-size: 11px; color: var(--muted); line-height: 1.7; }
.open-note strong { color: var(--ink); }

/* AI LAUNCH POPUP */
.popup-ai-row   { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.popup-ai-icon  { width: 44px; height: 44px; border-radius: 10px; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 20px; border: 1.5px solid var(--border); }
.popup-ai-name  { font-family: 'Bebas Neue', sans-serif; font-size: 26px; letter-spacing: .04em; color: var(--ink); }
.popup-ai-sub   { font-size: 9px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; margin-top: 1px; }

/* ── TEMPLATES PAGE ── */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.tmpl-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 8px; padding: 15px; cursor: pointer; transition: all .15s;
  position: relative; overflow: hidden;
}
.tmpl-card:hover { border-color: var(--border2); background: var(--surface2); transform: translateY(-1px); }
.tmpl-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--tc); }
.tmpl-cat    { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.tmpl-title  { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; color: var(--ink); margin-bottom: 7px; line-height: 1.3; }
.tmpl-preview{ font-size: 11px; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tmpl-vars   { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.tmpl-var    { background: var(--blue-bg); color: var(--blue); border: 1px solid #b0cef0; border-radius: 3px; padding: 2px 6px; font-size: 9px; letter-spacing: .06em; }

/* Fill Modal */
.fill-field  { margin-bottom: 12px; }
.fill-label  { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.fill-input  { width: 100%; background: var(--surface); border: 1.5px solid var(--border); border-radius: 6px; color: var(--ink); font-family: 'IBM Plex Mono', monospace; font-size: 12px; padding: 8px 12px; outline: none; transition: border-color .2s; }
.fill-input:focus { border-color: var(--ink); }
.fill-input::placeholder { color: var(--muted2); }
.fill-result { background: var(--surface); border: 1.5px solid var(--border); border-radius: 6px; padding: 12px 14px; font-size: 12px; color: var(--ink); line-height: 1.7; min-height: 80px; margin-bottom: 14px; white-space: pre-wrap; word-break: break-word; }

/* ── MASTER PROMPTS ── */
.master-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.master-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 8px; padding: 15px; cursor: pointer; transition: all .15s;
  position: relative; overflow: hidden;
}
.master-card:hover { border-color: var(--border2); background: var(--surface2); transform: translateY(-1px); }
.master-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--mc); }
.master-cat     { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.master-title   { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; color: var(--ink); margin-bottom: 7px; line-height: 1.3; }
.master-preview { font-size: 11px; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.master-footer  { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--border); }
.master-use     { font-size: 10px; color: var(--muted); }
.master-card:hover .master-use { color: var(--ink); }

/* ── LIBRARY PAGE ── */
.lib-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.folder-pills { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 12px; }
.folder-pill {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 5px;
  padding: 4px 12px; font-size: 10px; color: var(--muted); cursor: pointer;
  transition: all .15s; display: flex; align-items: center; gap: 5px;
}
.folder-pill:hover  { border-color: var(--border2); color: var(--ink); }
.folder-pill.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.lib-item {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 8px;
  padding: 13px 15px; transition: all .15s; display: flex;
  align-items: flex-start; gap: 11px; margin-bottom: 5px;
}
.lib-item:hover { border-color: var(--border2); background: var(--surface2); }
.lib-bar    { width: 4px; border-radius: 2px; flex-shrink: 0; align-self: stretch; min-height: 36px; }
.lib-body   { flex: 1; min-width: 0; }
.lib-title  { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; color: var(--ink); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-preview{ font-size: 11px; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-meta   { font-size: 9px; color: var(--muted2); margin-top: 4px; letter-spacing: .06em; text-transform: uppercase; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lib-rating { color: #c0940a; font-size: 11px; }
.lib-actions{ display: flex; gap: 4px; flex-shrink: 0; }

/* SAVE MODAL */
.save-preview-box {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 11px; color: var(--muted); line-height: 1.6;
  margin-bottom: 12px; max-height: 70px; overflow: hidden; position: relative;
}
.save-preview-box::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 16px; background: linear-gradient(transparent, var(--surface)); }
.save-fields  { display: flex; flex-direction: column; gap: 8px; }
.rating-row   { display: flex; gap: 4px; margin-top: 2px; }
.rating-star  { font-size: 18px; cursor: pointer; opacity: .3; transition: opacity .15s; }
.rating-star.on { opacity: 1; }

/* ── HISTORY PAGE ── */
.hist-item {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 7px;
  padding: 10px 13px; margin-bottom: 5px; display: flex; align-items: center;
  gap: 9px; transition: all .15s;
}
.hist-item:hover { border-color: var(--border2); background: var(--surface2); }
.hist-num  { font-size: 9px; color: var(--muted2); flex-shrink: 0; width: 18px; text-align: right; }
.hist-text { flex: 1; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-time { font-size: 9px; color: var(--muted2); white-space: nowrap; }

/* ── STATS PAGE ── */
.stats-big-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 24px; }
.big-stat        { background: var(--surface); border: 1.5px solid var(--border); border-radius: 8px; padding: 20px; position: relative; overflow: hidden; }
.big-stat::before{ content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--bs); }
.big-stat-val    { font-family: 'Bebas Neue', sans-serif; font-size: 48px; letter-spacing: .03em; color: var(--ink); line-height: 1; }
.big-stat-lbl    { font-size: 10px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; margin-top: 4px; }
.chart-bar-wrap  { margin-bottom: 8px; }
.chart-bar-label { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-bottom: 3px; }
.chart-bar-bg    { background: var(--border); border-radius: 3px; height: 8px; overflow: hidden; }
.chart-bar-fill  { height: 100%; border-radius: 3px; transition: width .6s ease; background: var(--bf, var(--ink)); }

/* ── CUSTOM AI PAGE ── */
.custom-form { background: var(--surface); border: 1.5px solid var(--border); border-radius: 8px; padding: 18px; margin-bottom: 16px; }
.form-grid   { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 7px; align-items: end; }
.custom-item { background: var(--surface); border: 1.5px solid var(--border); border-radius: 7px; padding: 11px 13px; display: flex; align-items: center; gap: 9px; margin-bottom: 5px; }
.custom-name { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; color: var(--ink); }
.custom-url  { font-size: 10px; color: var(--muted); }

/* ── BACKUP PAGE ── */
.backup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-bottom: 20px; }
.backup-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: 8px; padding: 18px; position: relative; overflow: hidden; }
.backup-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--bc); }
.backup-icon  { font-size: 26px; margin-bottom: 9px; }
.backup-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; color: var(--ink); margin-bottom: 3px; }
.backup-desc  { font-size: 11px; color: var(--muted); line-height: 1.5; margin-bottom: 12px; }

/* ── IMPROVE MODAL ── */
.api-note      { font-size: 11px; color: var(--muted); line-height: 1.6; margin-bottom: 14px; background: var(--yellow-bg); border: 1px solid #e8d080; border-radius: 6px; padding: 9px 12px; }
.api-key-row   { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.api-key-input { flex: 1; background: var(--surface); border: 1.5px solid var(--border); border-radius: 6px; color: var(--ink); font-family: 'IBM Plex Mono', monospace; font-size: 11px; padding: 7px 11px; outline: none; min-width: 160px; transition: border-color .2s; }
.api-key-input:focus { border-color: var(--ink); }
.api-key-input::placeholder { color: var(--muted2); }
.improve-original { background: var(--surface); border: 1.5px solid var(--border); border-radius: 6px; padding: 12px 14px; font-size: 12px; color: var(--muted); line-height: 1.7; margin-bottom: 14px; max-height: 100px; overflow: hidden; position: relative; }
.improve-original::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 20px; background: linear-gradient(transparent, var(--surface)); }
.improve-result  { background: var(--green-bg); border: 1.5px solid #a8dfc0; border-radius: 6px; padding: 14px; font-size: 12px; color: var(--ink); line-height: 1.7; margin-bottom: 14px; white-space: pre-wrap; word-break: break-word; display: none; }
.improve-loading { text-align: center; padding: 24px; color: var(--muted); font-size: 12px; display: none; }

@media (max-width: 600px) {
  .form-grid  { grid-template-columns: 1fr 1fr; }
  .ai-grid    { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
  .master-grid, .template-grid { grid-template-columns: 1fr; }
}
