
:root {
  --bg: #0d1015;
  --panel: #171b22;
  --panel-2: #202630;
  --panel-3: #282f3b;
  --text: #f6f7f9;
  --muted: #aab2bf;
  --accent: #ffb000;
  --accent-2: #ffd269;
  --border: #343c49;
  --danger: #ff6b6b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  background:
    radial-gradient(circle at 50% -15%, rgba(255,176,0,.15), transparent 36%),
    radial-gradient(circle at 100% 25%, rgba(77,92,118,.16), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, select, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(255,176,0,.35);
  outline-offset: 2px;
}
.app-shell { width: min(760px, 100%); margin: 0 auto; padding: 20px 0 34px; }
.topbar { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-logo { width: 58px; height: 58px; flex: 0 0 auto; filter: drop-shadow(0 8px 20px rgba(0,0,0,.25)); }
h1 { margin: 0; font-size: clamp(1.65rem, 5vw, 2.25rem); letter-spacing: -.035em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: .91rem; }
.header-actions { display: flex; gap: 8px; }
.icon-button, .ghost, .danger-ghost {
  border: 1px solid var(--border);
  background: rgba(23,27,34,.88);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  white-space: nowrap;
}
.icon-button span { color: var(--accent-2); font-weight: 800; }
.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(23,27,34,.78);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 5px;
  margin-bottom: 14px;
}
.mode-tab {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}
.mode-tab.active { background: var(--panel-3); color: var(--text); box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.mode-panel {
  display: none;
  background: rgba(23,27,34,.88);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  margin-bottom: 12px;
}
.mode-panel.active { display: block; animation: panelIn .18s ease-out; }
@keyframes panelIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.control-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: .92rem; }
select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 13px;
}
textarea { resize: vertical; min-height: 88px; line-height: 1.4; }
.suggestion-wrap { margin-top: 12px; color: var(--muted); font-size: .84rem; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.chip {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: .8rem;
}
.level-control {
  background: rgba(23,27,34,.7);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 15px 10px;
  margin-bottom: 14px;
}
.level-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .92rem; }
.level-head strong { color: var(--accent-2); }
input[type="range"] { width: 100%; margin: 13px 0 8px; accent-color: var(--accent); }
.level-scale { display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; font-size: .68rem; color: #7f8998; text-align: center; }
.quote-card {
  position: relative;
  min-height: 275px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 25px;
  padding: 38px 30px 25px;
  background:
    linear-gradient(145deg, rgba(38,45,57,.98), rgba(22,26,33,.98));
  box-shadow: 0 26px 70px rgba(0,0,0,.28);
}
.quote-card.flash { animation: quoteIn .24s ease-out; }
@keyframes quoteIn { from { opacity: .55; transform: scale(.992); } to { opacity: 1; transform: none; } }
.quote-decoration {
  position: absolute;
  top: -40px;
  left: 18px;
  color: rgba(255,176,0,.14);
  font-family: Georgia, serif;
  font-size: 10rem;
  line-height: 1;
}
#quote {
  position: relative;
  margin: 0;
  font-size: clamp(1.42rem, 4.8vw, 2.05rem);
  line-height: 1.36;
  font-weight: 760;
  letter-spacing: -.024em;
  text-wrap: balance;
}
.quote-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
  color: var(--accent-2);
  font-size: .84rem;
}
#remaining { color: var(--muted); text-align: right; }
.roulette-button {
  width: 100%;
  min-height: 60px;
  margin: 17px 0 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 16px;
  padding: 17px 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #201609;
  font-size: 1.08rem;
  font-weight: 850;
  box-shadow: 0 12px 34px rgba(255,176,0,.17);
}
.roulette-button:active { transform: translateY(1px); }
.button-arrow { font-size: 1.3rem; }
.roulette-button.compact { min-height: 50px; margin-bottom: 0; }
.actions { display: grid; grid-template-columns: repeat(4,1fr); gap: 9px; }
.actions button, .item-actions button {
  border: 1px solid var(--border);
  background: rgba(23,27,34,.9);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 8px;
}
.actions button[aria-pressed="true"] { color: var(--accent-2); border-color: rgba(255,176,0,.45); }
.status { min-height: 24px; margin: 12px 0 0; color: var(--accent-2); text-align: center; font-size: .88rem; }
footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 30px;
  color: #7f8998;
  font-size: .77rem;
}
dialog {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 35px 100px rgba(0,0,0,.5);
}
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
.list-dialog { width: min(700px, calc(100% - 24px)); max-height: 84vh; }
.card-dialog { width: min(620px, calc(100% - 24px)); max-height: 92vh; }
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  position: sticky;
  top: -18px;
  z-index: 2;
  margin: -18px -18px 10px;
  padding: 18px;
  background: rgba(13,16,21,.97);
  border-bottom: 1px solid var(--border);
}
.dialog-head h2 { margin: 0; }
.dialog-head p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }
.dialog-tools { display: flex; justify-content: flex-end; margin: 8px 0 12px; }
.danger-ghost { color: var(--danger); }
.list-item {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 14px;
  padding: 14px;
  margin: 10px 0;
}
.list-item p { margin: 0 0 10px; font-weight: 650; line-height: 1.42; }
.list-item small { display: block; color: var(--muted); margin-bottom: 10px; }
.item-actions { display: flex; gap: 8px; }
.item-actions button { padding: 8px 10px; font-size: .82rem; }
.empty-state { color: var(--muted); text-align: center; padding: 32px 12px; }
.format-label { margin: 14px 0; }
.canvas-wrap {
  width: 100%;
  max-height: 58vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #090b0f;
  padding: 10px;
}
#cardCanvas { display: block; width: 100%; height: auto; border-radius: 8px; }
@media (max-width: 620px) {
  body { padding-left: 12px; padding-right: 12px; }
  .app-shell { padding-top: 14px; }
  .brand-logo { width: 49px; height: 49px; }
  .brand p { display: none; }
  .header-actions { gap: 6px; }
  .icon-button { padding: 9px 10px; }
  .mode-tab { font-size: .82rem; }
  .quote-card { min-height: 300px; padding: 34px 22px 22px; }
  .quote-footer { flex-direction: column; gap: 5px; }
  #remaining { text-align: left; }
  .actions { grid-template-columns: repeat(2,1fr); }
  footer { flex-direction: column; gap: 6px; text-align: center; }
}
@media (max-width: 370px) {
  .mode-tab { font-size: .75rem; padding-inline: 3px; }
  h1 { font-size: 1.45rem; }
}
