/* Platinum Helper — web theme ported from platinum_helper/theme.py */
:root {
  --bg: #0b0f17;
  --bg-alt: #121a28;
  --card: #172032;
  --card-hover: #1d283d;
  --border: #26324a;
  --border-soft: #1e2739;
  --text: #e8edf7;
  --muted: #8593ab;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --accent-deep: #3567d6;
  --gold: #eac36a;
  --green: #3fd18b;
  --red: #ef6b6b;
  --bronze: #d0864f;
  --silver: #c6cfde;
  --platinum: #9fd8ff;
  --radius-card: 14px;
  --radius-btn: 9px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }
body { min-height: 100vh; }
a { color: var(--accent); }
button, input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.mobile-only { display: none !important; }
@media (max-width: 720px) { .mobile-only { display: inline-flex !important; } .desktop-only { display: none !important; } }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.col { display: flex; flex-direction: column; gap: 8px; }

/* ---------- App shell ---------- */
#app { max-width: 1600px; margin: 0 auto; padding: 16px 24px 60px;
  /* Standalone (home-screen) mode on iOS draws behind the status bar / notch. */
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-left: calc(18px + env(safe-area-inset-left, 0px));
  padding-right: calc(18px + env(safe-area-inset-right, 0px));
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }

.app-header { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; flex-wrap: wrap; }
.app-header .brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.app-header .brand img { width: 44px; height: 44px; border-radius: 10px; }
.app-header h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0.2px; }
.app-header .subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.app-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 10px; align-items: center; padding: 6px 0 14px; flex-wrap: wrap; }
.toolbar input[type="search"], .toolbar input[type="text"] { flex: 1; min-width: 220px; }

/* ---------- Inputs ---------- */
input[type="text"], input[type="search"], input[type="password"], input[type="email"], input[type="number"], input[type="url"], select, textarea {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius-btn);
  padding: 9px 12px; outline: none; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
select { cursor: pointer; width: auto; appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
select option { background: var(--bg-alt); color: var(--text); }
textarea { min-height: 84px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label.field > span { font-weight: 600; }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: 13px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
input[type="number"] { width: 120px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-btn);
  border: 1px solid var(--border); background: var(--bg-alt); color: var(--text); cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s; text-decoration: none; }
.btn:hover { background: var(--card-hover); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); border-color: transparent; color: #fff; }
.btn.primary:hover { background: linear-gradient(135deg, var(--accent-hover), var(--accent)); }
.btn.danger { color: var(--red); border-color: rgba(239,107,107,.35); }
.btn.danger:hover { background: rgba(239,107,107,.12); border-color: var(--red); }
.btn.discord { background: #5865F2; border-color: #5865F2; color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.btn.discord:hover { background: #4752C4; border-color: #4752C4; color: #fff; }
.btn.github { background: #24292f; border-color: #3d444d; color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.btn.github:hover { background: #32383f; border-color: #5a626b; color: #fff; }
.discord-icon { display: inline-flex; line-height: 0; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 10px; }
.btn.ghost:hover { color: var(--text); background: var(--card-hover); border-color: var(--border); }
.btn.icon { padding: 8px 10px; font-size: 16px; line-height: 1; }
.refresh-glyph { display: inline-block; }
.btn.icon.spinning .refresh-glyph { animation: ph-spin .8s linear infinite; }
@keyframes ph-spin { to { transform: rotate(360deg); } }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.success { color: var(--green); border-color: rgba(63,209,139,.35); }
.btn.success:hover { background: rgba(63,209,139,.12); border-color: var(--green); }

.counter-btn { width: 116px; height: 76px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg-alt);
  color: var(--text); font-size: 32px; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.counter-btn small { font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.counter-btn:hover { background: var(--card-hover); border-color: var(--accent); }
.counter-btn.done { color: var(--green); border-color: rgba(63,209,139,.45); background: rgba(63,209,139,.08); }
.counter-btn:disabled { opacity: .6; cursor: default; }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px;
  border: 1px solid; white-space: nowrap; }
.pill.accent { color: var(--accent-hover); border-color: rgba(79,140,255,.45); background: rgba(79,140,255,.12); }
.pill.gold { color: var(--gold); border-color: rgba(234,195,106,.45); background: rgba(234,195,106,.12); }
.pill.silver { color: var(--silver); border-color: rgba(198,207,222,.45); background: rgba(198,207,222,.10); }
.pill.bronze { color: var(--bronze); border-color: rgba(208,134,79,.45); background: rgba(208,134,79,.12); }
.pill.platinum { color: var(--platinum); border-color: rgba(159,216,255,.5); background: rgba(159,216,255,.12); }
.pill.green { color: var(--green); border-color: rgba(63,209,139,.45); background: rgba(63,209,139,.12); }
.pill.orange { color: #f5a742; border-color: rgba(245,167,66,.5); background: rgba(245,167,66,.13); }
.pill.red { color: #ff6b6b; border-color: rgba(255,107,107,.5); background: rgba(255,107,107,.13); }
.pill.muted { color: var(--muted); border-color: var(--border); background: var(--bg-alt); }
/* Clickable pill (e.g. "Tags ▾") */
button.pill { cursor: pointer; font: inherit; font-size: 11.5px; font-weight: 700; gap: 4px; line-height: inherit; }
button.pill:hover { filter: brightness(1.15); }
.pill .caret { font-size: 10px; opacity: .8; }
/* PSNProfiles-style guide tags: solid fill, uppercase */
.tag-list { gap: 8px; }
.pill.tag { text-transform: uppercase; letter-spacing: .6px; padding: 6px 16px; font-size: 12px; border-color: transparent; color: #fff; }
.pill.tag.orange { background: #e8891c; }
.pill.tag.red { background: #c9484a; }
.pill.tag.green { background: #3aa76d; }
.pill.tag.blue { background: #3c7dd9; }
.pill.tag.yellow { background: #c9a227; }
.pill.tag.purple { background: #7c5cbf; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--radius-card); padding: 14px 16px; }
.card:hover { border-color: var(--border); }

.projects-grid { display: flex; flex-direction: column; gap: 14px; }

.project-card { display: flex; gap: 14px; }
.project-card.platinum { background: linear-gradient(135deg, #24354a, #273b4f); border-color: #79b9d4; }
.project-card .cover { width: 128px; height: 128px; flex: none; border-radius: 10px; background: var(--bg-alt); border: 1px solid var(--border-soft);
  object-fit: cover; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 28px; font-weight: 700; overflow: hidden; }
.project-card .cover img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.project-card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.project-card .head { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.project-card .title { font-size: 17px; font-weight: 700; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.project-card .title:hover { color: var(--accent-hover); }
.project-card .notes { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
.project-card .stats { color: var(--muted); font-size: 12.5px; }
.project-card .stats.done { color: var(--platinum); font-weight: 600; }
.project-card .buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }

/* progress bar */
.progress { display: flex; align-items: center; gap: 10px; }
.progress .bar { flex: 1; height: 9px; border-radius: 6px; background: var(--bg-alt); border: 1px solid var(--border-soft); overflow: hidden; }
.progress .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7ee0b5); border-radius: 6px; transition: width .25s; }
.progress .pct { min-width: 40px; text-align: right; font-size: 12px; color: var(--muted); font-weight: 600; }
.progress.big .bar { height: 12px; }

/* ---------- Project page ---------- */
.project-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 4px 0 12px; }
.project-head .cover { width: 72px; height: 72px; flex: none; border-radius: 10px; overflow: hidden; background: #0f1624; border: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; font-size: 20px; }
.project-head .cover img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.project-head .title { flex: 1 1 260px; min-width: 0; }
.project-head h2 { margin: 0; font-size: 20px; }
.project-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.project-head .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; flex: 0 1 auto; }
/* Keep back-button + cover + title on one line; actions drop to their own row when there's no room. */
@media (max-width: 1400px) and (min-width: 721px) {
  .project-head .actions { flex-basis: 100%; margin-left: 0; }
}

.trophy-list { display: flex; flex-direction: column; gap: 10px; }
.trophy-card { display: flex; gap: 14px; align-items: stretch; }
.trophy-card.popped { border-color: rgba(63,209,139,.35); }
.trophy-card .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.trophy-card .name { font-weight: 700; font-size: 15px; color: var(--gold); cursor: pointer; }
.trophy-card .name:hover { text-decoration: underline; }
.trophy-card .name.plain { cursor: default; }
.trophy-card .name.plain:hover { text-decoration: none; }
.trophy-card .desc { color: var(--text); font-size: 13px; opacity: .92; }
.trophy-card .meta { color: var(--muted); font-size: 12px; }
.trophy-card .note { border-left: 3px solid var(--accent); background: var(--bg-alt); padding: 8px 10px; border-radius: 6px; font-size: 12.5px; white-space: pre-wrap; color: var(--text); }
.trophy-card .side { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6px; flex: none; }
.trophy-card .side .row { justify-content: flex-end; }
.star { cursor: pointer; font-size: 16px; color: var(--muted); user-select: none; line-height: 1; padding: 0 2px; }
.star.on { color: var(--gold); }
.star:hover { color: var(--gold); }

.empty { text-align: center; color: var(--muted); padding: 60px 10px; }
.empty h3 { color: var(--text); margin: 0 0 6px; }

/* ---------- Auth / welcome ---------- */
.auth-wrap { max-width: 420px; margin: 8vh auto 0; }
.auth-wrap .card { padding: 24px; }
.auth-wrap h1 { margin: 0 0 4px; font-size: 24px; }
.auth-wrap form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.auth-wrap .switch { text-align: center; margin-top: 12px; color: var(--muted); font-size: 13px; }
.auth-wrap .switch a { cursor: pointer; }
.welcome-wrap { max-width: 560px; margin: 6vh auto 0; }
.welcome-wrap .card { padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.welcome-wrap h1 { margin: 0; font-size: 24px; }
.brand-big { display: flex; align-items: center; gap: 14px; }
.brand-big img { width: 64px; height: 64px; border-radius: 14px; }
.welcome-center { justify-content: center; flex-wrap: wrap; text-align: center; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4,7,12,.72); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); width: 100%; max-width: 560px; max-height: 92vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.55); }
.modal.wide { max-width: 760px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border-soft); }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 18px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
.modal-footer .left { margin-right: auto; }

/* settings */
.settings-section { display: flex; flex-direction: column; gap: 10px; }
.settings-section h3 { margin: 0; font-size: 14px; color: var(--accent-hover); text-transform: uppercase; letter-spacing: .6px; }
.settings-section p { margin: 0; color: var(--muted); font-size: 12.5px; }
.settings-section .sub-heading { margin: 8px 0 0; font-size: 12.5px; color: var(--text); font-weight: 600; letter-spacing: .3px; }
.install-steps { margin: 0; padding-left: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.install-steps li { counter-increment: step; position: relative; padding-left: 38px; line-height: 1.45; font-size: 14px; }
.install-steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.install-steps b { color: var(--accent-hover); }
.wizard-dots { display: flex; justify-content: center; gap: 6px; margin-top: 18px; }
.wizard-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.wizard-dots i.on { background: var(--accent); }
hr.sep { border: none; border-top: 1px solid var(--border-soft); margin: 4px 0; }

/* PSN search list */
.result-list { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: auto; border: 1px solid var(--border-soft); border-radius: 10px; padding: 6px; background: var(--bg-alt); }
.result-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.result-item:hover { background: var(--card-hover); }
.result-item.selected { border-color: var(--accent); background: rgba(79,140,255,.12); }
.result-item img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--card); flex: none; }
.result-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-item .s { color: var(--muted); font-size: 12px; }

/* summary lines */
.summary { background: var(--bg-alt); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--card); border: 1px solid var(--border);
  color: var(--text); padding: 10px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.error { border-color: var(--red); }
#toast.success { border-color: var(--green); }

.loading { text-align: center; color: var(--muted); padding: 40px; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  html, body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
  #app { padding-left: calc(12px + env(safe-area-inset-left, 0px)); padding-right: calc(12px + env(safe-area-inset-right, 0px)); }
  /* iOS Safari zooms into any focused input with font-size < 16px. */
  input[type="text"], input[type="search"], input[type="password"], input[type="email"], input[type="number"], input[type="url"], select, textarea { font-size: 16px; }
  input[type="number"] { width: 100%; }
  .app-header { gap: 10px; }
  .app-header .brand { width: 100%; margin-right: 0; }
  .app-header .brand .brand-text { flex: 1; min-width: 0; }
  .app-header .brand img { width: 40px; height: 40px; }
  .app-header h1 { font-size: 20px; }
  .app-header .actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .app-header .actions .btn { width: 100%; }
  .app-header .actions .btn.primary { grid-column: span 2; }
  .toolbar { gap: 8px; }
  .toolbar input[type="search"] { min-width: 0; width: 100%; flex: 1 1 100%; }
  .toolbar select { flex: 1; width: auto; }
  .card { padding: 12px; }

  /* Run cards: cover + title/pills side by side, everything else full width underneath. */
  .projects-grid { gap: 12px; }
  .project-card { display: grid; grid-template-columns: 72px 1fr; gap: 10px 12px; padding: 12px; }
  .project-card .cover { width: 72px; height: 72px; border-radius: 12px; }
  .project-card .body { display: contents; }
  .project-card .head { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
  .project-card .title { white-space: normal; font-size: 16px; line-height: 1.25;
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .project-card .pills { gap: 5px; }
  .project-card .notes, .project-card .progress, .project-card .stats, .project-card .buttons { grid-column: 1 / -1; }
  .project-card .notes { -webkit-line-clamp: 1; line-clamp: 1; }
  .project-card .stats { font-size: 12px; }
  .project-card .buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 2px; }
  .project-card .buttons .btn { width: 100%; padding: 8px 6px; font-size: 12.5px; }
  .project-card .buttons .btn.primary { grid-column: 1 / -1; }
  .pill { font-size: 11px; padding: 2px 8px; }
  .project-head { gap: 10px; }
  .project-head .actions { width: 100%; margin-left: 0; display: grid; grid-template-columns: 1fr 1fr; }
  .project-head .actions .btn { width: 100%; }
  .project-head h2 { font-size: 18px; }
  .trophy-card { flex-direction: column; }
  .trophy-card .side { flex-direction: row; align-items: center; justify-content: space-between; }
  .trophy-card .side .row { justify-content: flex-start; }
  .counter-btn { width: 96px; height: 64px; font-size: 26px; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: none; max-height: 94vh; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .modal-footer .btn { flex: 1 1 auto; }
  #toast { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .auth-wrap, .welcome-wrap { margin-top: 4vh; }
}
