:root {
    --bg0: #dff1ea;
    --bg: #f4fbf7;
    --ink: #14201f;
    --muted: #5b6b69;
    --brand: #0f3d3e;
    --brand-2: #1f6f70;
    --accent: #e08a3c;
    --accent-2: #c46b22;
    --ok: #2f8f5b;
    --bad: #b33a3a;
    --card: rgba(255, 255, 255, 0.78);
    --line: rgba(20, 32, 31, 0.12);
    --shadow: 0 18px 50px rgba(15, 61, 62, 0.12);
    --radius: 18px;
    --font: "Source Sans 3", system-ui, sans-serif;
    --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 10% -10%, #b7e4d4 0%, transparent 55%),
        radial-gradient(900px 500px at 100% 0%, #f3d3a8 0%, transparent 50%),
        linear-gradient(180deg, var(--bg0), var(--bg) 40%, #eef7f2);
    line-height: 1.45;
}

a { color: var(--brand-2); }
.app-shell { max-width: 720px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.topbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: .75rem; margin-bottom: 1rem;
}
.brand {
    font-family: var(--display); font-weight: 700; font-size: 1.45rem;
    color: var(--brand); text-decoration: none;
}
.nav { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; }
.nav a, .linkish {
    color: var(--muted); text-decoration: none; font-weight: 600; background: none; border: 0; cursor: pointer; font: inherit;
}
.nav a.active, .nav a:hover, .linkish:hover { color: var(--brand); }
.inline { display: inline; margin: 0; }

.flash {
    background: #e7f6ec; border: 1px solid #b9dfc6; color: #215c3a;
    padding: .75rem 1rem; border-radius: 12px; margin-bottom: 1rem;
}
.flash-error { background: #fdeceb; border-color: #f0b4b0; color: #7a2424; }
.flash ul { margin: 0; padding-left: 1.1rem; }

.main h1, .main h2 { font-family: var(--display); color: var(--brand); margin: 0 0 .4rem; }
.hero-block p, .muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

.login-hero { padding-top: 12vh; text-align: center; }
.login-hero h1 { font-size: clamp(2.4rem, 8vw, 3.4rem); margin-bottom: .25rem; }
.login-hero p { margin-bottom: 1.5rem; }

.card-form, .recorder-panel, .canned-panel, .history-preview, .narrow {
    background: var(--card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem;
    margin-bottom: 1rem;
}
.card-form label, .target-row label { display: grid; gap: .35rem; font-weight: 600; margin-bottom: .85rem; }
input[type=email], input[type=password], input[type=text], select {
    width: 100%; border: 1px solid var(--line); border-radius: 12px;
    padding: .75rem .9rem; font: inherit; background: #fff;
}
.check { display: flex !important; align-items: center; gap: .5rem; font-weight: 500 !important; }

.btn, button.btn {
    appearance: none; border: 0; border-radius: 999px; padding: .75rem 1.15rem;
    font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex;
    align-items: center; justify-content: center; gap: .4rem;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-block { width: 100%; }
.btn-canned {
    width: 100%; background: #fff7ee; color: var(--accent-2);
    border: 1px solid #f0d2b0; border-radius: 14px; padding: 1rem; font-weight: 700;
}

.device-strip { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.device-chip {
    display: flex; align-items: center; gap: .45rem;
    background: var(--card); border: 1px solid var(--line); border-radius: 999px;
    padding: .4rem .75rem; font-size: .92rem;
}
.device-chip .dot { width: .55rem; height: .55rem; border-radius: 50%; background: #9aa; }
.device-chip.online .dot { background: var(--ok); }
.device-chip.offline .dot { background: #b0b8b6; }
.online-text { color: var(--ok); font-weight: 700; }
.offline-text { color: var(--muted); font-weight: 700; }

.btn-record {
    width: 100%; min-height: 160px; border: 0; border-radius: 28px; cursor: pointer;
    background: linear-gradient(160deg, var(--accent), var(--accent-2));
    color: #fff; box-shadow: 0 16px 40px rgba(196, 107, 34, 0.35);
    display: grid; place-items: center; gap: .6rem; font: inherit; font-weight: 700; font-size: 1.15rem;
}
.btn-record.recording {
    background: linear-gradient(160deg, #c44747, #8f1f1f);
    animation: pulse 1.2s ease-in-out infinite;
}
.rec-icon {
    width: 28px; height: 28px; border-radius: 50%; background: #fff;
    box-shadow: inset 0 0 0 6px rgba(255,255,255,.25);
}
.btn-record.recording .rec-icon { border-radius: 6px; width: 22px; height: 22px; }
@keyframes pulse { 50% { transform: scale(0.985); } }

.preview-wrap { margin-top: 1rem; display: grid; gap: .75rem; }
.preview-actions { display: flex; gap: .5rem; }
.preview-actions .btn { flex: 1; }

.canned-grid { display: grid; gap: .6rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; gap: .75rem; }
.device-list, .message-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .65rem; }
.device-row, .message-list li {
    display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap;
    background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .85rem 1rem;
}
.status { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.status-sent { color: #7a6a20; }
.status-received { color: #1f5f9a; }
.status-played { color: var(--ok); }
.status-failed { color: var(--bad); }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .55rem; }
