@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Source+Sans+3:wght@400;600;700&display=swap");

:root {
    --bg: #e8eef4;
    --bg-deep: #d5e0ea;
    --surface: #ffffff;
    --ink: #132033;
    --muted: #5b6b7c;
    --accent: #0b6e6a;
    --accent-2: #c45c26;
    --ok: #1f7a4c;
    --warn: #a86b00;
    --danger: #a11d2e;
    --border: #c7d3de;
    --shadow: 0 10px 30px rgba(19, 32, 51, 0.08);
    --radius: 14px;
    --font: "Source Sans 3", "Segoe UI", sans-serif;
    --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 10% -10%, #f7fbff 0%, transparent 60%),
        radial-gradient(900px 500px at 100% 0%, #f3ebe3 0%, transparent 55%),
        linear-gradient(180deg, var(--bg), var(--bg-deep));
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.4rem;
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-brand a {
    font-family: var(--display);
    font-size: 1.25rem;
    color: var(--ink);
    text-decoration: none;
}
.topbar-nav { display: flex; gap: 1rem; align-items: center; }
.topbar-user { color: var(--muted); font-size: 0.92rem; }

.container { width: min(1100px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }
.page-head { margin-bottom: 1rem; }
.page-head h1, .auth-card h1, .public-card h1 {
    font-family: var(--display);
    margin: 0.2rem 0 0.4rem;
    letter-spacing: -0.02em;
}

.panel, .auth-card, .public-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.35rem;
    margin-bottom: 1.2rem;
}
.panel h2 { margin-top: 0; font-size: 1.05rem; }
.panel-danger { border-color: #efc2c8; }

.muted { color: var(--muted); }
.stack { display: grid; gap: 0.9rem; }
.form-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.form-actions { display: flex; align-items: end; }
label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.92rem; }
label.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    font: inherit;
    background: #fbfcfe;
}
textarea { resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    border-radius: 999px;
    padding: 0.55rem 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { text-decoration: none; background: #f3f7fa; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #095955; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.88rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.flash {
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-weight: 600;
}
.flash-success, .flash-ok { background: #e5f6ec; color: var(--ok); }
.flash-error { background: #fde8eb; color: var(--danger); }
.flash-warn { background: #fff4df; color: var(--warn); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.4rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.78rem;
    background: #eef2f6;
    color: var(--muted);
    margin-right: 0.25rem;
}
.badge-ok { background: #e5f6ec; color: var(--ok); }
.badge-warn { background: #fff4df; color: var(--warn); }
.badge-live { background: #e7f3f2; color: var(--accent); }

.auth-body, .public-body {
    display: grid;
    place-items: center;
    padding: 1.5rem;
}
.auth-card, .public-card { width: min(480px, 100%); }
.public-card { width: min(560px, 100%); }

.hp {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

@media (max-width: 640px) {
    .topbar { padding: 0.8rem 1rem; }
    .container { width: calc(100% - 1.2rem); }
}

.container-wide { width: min(1500px, calc(100% - 1.2rem)); }
.page-head-row { display:flex; justify-content:space-between; gap:1rem; align-items:flex-start; flex-wrap:wrap; }
.hidden { display:none !important; }
.small { font-size:0.85rem; }
.soft { border:0; border-top:1px solid var(--border); margin:1rem 0; }

.badge-new { background:#e8eefc; color:#2a4a9b; }
.badge-prepared { background:#fff4df; color:var(--warn); }
.badge-answered { background:#e5f6ec; color:var(--ok); }

.qr-wrap { display:flex; gap:1.2rem; align-items:center; flex-wrap:wrap; margin-top:0.8rem; }
.qr-wrap canvas { border:1px solid var(--border); border-radius:12px; background:#fff; }

.edit-grid, .present-grid, .designer-grid {
    display:grid;
    gap:1rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 1100px) {
    .edit-grid, .present-grid, .designer-grid { grid-template-columns: 1fr; }
}
.edit-col h2, .edit-col h3 { margin-top:0; }
.subhead { font-size:0.95rem; color:var(--muted); margin:1rem 0 0.5rem; }

.playlist { display:flex; flex-direction:column; gap:0.45rem; min-height:2rem; }
.q-item {
    display:grid;
    grid-template-columns: auto 1fr auto;
    gap:0.35rem;
    align-items:stretch;
    border:1px solid var(--border);
    border-radius:12px;
    background:#fbfcfe;
    padding:0.25rem;
}
.q-item.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.q-item .grip { border:0; background:transparent; cursor:grab; color:var(--muted); padding:0.4rem; }
.q-item .q-main {
    border:0; background:transparent; text-align:left; cursor:pointer; padding:0.35rem;
    display:flex; flex-direction:column; gap:0.15rem; font:inherit; color:inherit;
}
.q-snip { color:var(--muted); font-size:0.86rem; }

.slide-preview {
    border:1px solid var(--border);
    border-radius:12px;
    overflow:hidden;
    background:#0f1720;
    width:100%;
}
.slide-preview-sm { max-width:100%; }
.preview-tools { display:flex; gap:0.6rem; align-items:center; }
.meta-line { display:flex; flex-wrap:wrap; gap:0.5rem; align-items:center; }

.present-top {
    display:flex; justify-content:space-between; gap:1rem; flex-wrap:wrap;
    align-items:flex-start; margin-bottom:0.6rem;
}
.present-controls { display:flex; flex-wrap:wrap; gap:0.5rem; align-items:center; }
.mode-switch { display:flex; gap:0.5rem; align-items:center; font-weight:700; }
.present-playlist { display:flex; flex-direction:column; gap:0.4rem; max-height:70vh; overflow:auto; }
.present-item {
    text-align:left; border:1px solid var(--border); border-radius:12px; padding:0.55rem 0.7rem;
    background:#fff; cursor:pointer; display:flex; flex-direction:column; gap:0.15rem; font:inherit;
}
.present-item.active { border-color:var(--accent); background:#e7f3f2; }
.present-speaker .speaker-author { font-family:var(--display); font-size:1.6rem; }
.speaker-question {
    font-size:1.25rem; line-height:1.35; margin:0.8rem 0 1rem; white-space:pre-wrap;
}
.speaker-notes {
    white-space:pre-wrap; background:#f6f8fb; border:1px solid var(--border);
    border-radius:12px; padding:0.8rem; min-height:8rem; font:inherit;
}
.timer-row { display:flex; gap:0.5rem; align-items:center; margin:0.6rem 0 1rem; }
.timer-bar { flex:1; height:10px; background:#e5ebf1; border-radius:999px; overflow:hidden; }
#timer-fill { height:100%; width:0; background:var(--accent); transition: width 0.2s linear; }

.designer-grid { grid-template-columns: 320px 1fr; }
@media (max-width: 1100px) { .designer-grid { grid-template-columns: 1fr; } }
.designer-canvas-wrap { overflow:auto; }
.designer-canvas {
    position:relative; margin:0 auto; border:1px solid var(--border); border-radius:8px;
    overflow:hidden; background:#d9e2ea; user-select:none;
}
.designer-bg { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; pointer-events:none; }
.designer-box {
    position:absolute; border:2px dashed rgba(11,110,106,0.85); background:rgba(11,110,106,0.08);
    color:#132033; font-size:12px; font-weight:700; box-sizing:border-box;
}
.designer-box.active { border-style:solid; background:rgba(11,110,106,0.16); }
.designer-box.hidden-box { opacity:0.35; }
.designer-box span { display:block; padding:4px 6px; pointer-events:none; }
.designer-box .handle {
    position:absolute; width:10px; height:10px; background:var(--accent); border-radius:2px;
}
.designer-box .handle.n { top:-5px; left:50%; margin-left:-5px; cursor:ns-resize; }
.designer-box .handle.s { bottom:-5px; left:50%; margin-left:-5px; cursor:ns-resize; }
.designer-box .handle.e { right:-5px; top:50%; margin-top:-5px; cursor:ew-resize; }
.designer-box .handle.w { left:-5px; top:50%; margin-top:-5px; cursor:ew-resize; }
.designer-box .handle.se { right:-5px; bottom:-5px; cursor:nwse-resize; }
.box-tabs { display:flex; gap:0.4rem; margin:1rem 0 0.8rem; flex-wrap:wrap; }
.box-tabs .active { background:var(--accent); color:#fff; border-color:var(--accent); }
.props label { font-weight:600; }
.user-row { margin-bottom:0.4rem; }

.layer-list { display:flex; flex-wrap:wrap; gap:0.35rem; min-height:1.5rem; }
.layer-btn.active { background:var(--accent); color:#fff; border-color:var(--accent); }
.copy-details { position:relative; }
.copy-details > summary { list-style:none; cursor:pointer; }
.copy-details > summary::-webkit-details-marker { display:none; }
.copy-form {
    position:absolute; right:0; top:calc(100% + 6px); z-index:5;
    background:#fff; border:1px solid var(--border); border-radius:12px;
    padding:0.8rem; box-shadow:var(--shadow); min-width:240px;
}
.form-fields-config {
    grid-column: 1 / -1;
    margin-top: 0.4rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border);
}
.form-fields-config h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.form-fields-config table input[type="text"] { min-width: 180px; }
