:root {
    --ink: #f4f1ea;
    --bg: #12101a;
    --panel: #1c1a26;
    --panel-2: #262433;
    --muted: #9c98ad;
    --accent: #f6b93b;
    --danger: #e55039;
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

/* Several components below are flex containers, which would otherwise win
   against the hidden attribute. */
[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

h1,
h2 {
    margin: 0 0 0.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

p {
    margin: 0 0 0.6rem;
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.85rem;
}

.grow {
    flex: 1;
    min-width: 0;
}

/* ---------- shared shell ---------- */

.sheet {
    max-width: 34rem;
    margin: 0 auto;
    padding: 1.5rem 1.1rem 4rem;
}

.sheet.wide {
    max-width: 56rem;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.row.between {
    justify-content: space-between;
}

.card {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

input[type="text"],
input[type="password"] {
    flex: 1;
    min-width: 8rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid #35323f;
    background: var(--panel-2);
    color: var(--ink);
    font-size: 1rem;
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.85rem 1.2rem;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: #241b06;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.btn.small {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
}

.btn.ghost {
    background: var(--panel-2);
    color: var(--ink);
}

.btn.danger {
    background: transparent;
    color: var(--danger);
    box-shadow: inset 0 0 0 1px var(--danger);
}

.btn[disabled] {
    opacity: 0.5;
    pointer-events: none;
}

.alert,
.notice {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: rgba(229, 80, 57, 0.15);
    color: #ffb1a2;
}

.notice {
    background: rgba(56, 173, 169, 0.15);
    color: #9fe6e3;
}

.link-box {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.link-box label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar.large {
    width: 96px;
    height: 96px;
}

.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #241b06;
    font-weight: 800;
}

.avatar.placeholder {
    font-size: 1rem;
}

.avatar.large.placeholder {
    font-size: 2rem;
}

.member-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.member-list form {
    display: inline;
}

/* ---------- family portal ---------- */

.portal-head {
    text-align: center;
    margin-bottom: 1.5rem;
}

.avatar-button {
    position: relative;
    display: inline-block;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    margin-bottom: 0.75rem;
}

.avatar-button .avatar {
    margin: 0 auto;
}

.avatar-edit {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: var(--accent);
    color: #241b06;
    font-size: 0.7rem;
    font-weight: 700;
}

.segmented {
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: 999px;
    background: var(--panel-2);
    margin-bottom: 1rem;
}

.segment {
    flex: 1;
    padding: 0.6rem;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.segment.is-active {
    background: var(--panel);
    color: var(--ink);
}

.stage {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

#preview {
    transform: scaleX(-1);
}

.audio-stage {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: radial-gradient(circle at center, #2c2740, #12101a);
}

.mic {
    color: var(--muted);
    font-weight: 600;
}

.pulse-ring {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.35;
    animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse {
    0% { transform: scale(0.85); opacity: 0.5; }
    70% { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

.stage audio {
    position: absolute;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    width: calc(100% - 2rem);
    z-index: 2;
}

.stage-message {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.85rem;
    white-space: nowrap;
}

.timer {
    position: absolute;
    top: 0.8rem;
    left: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.timer::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--danger);
    animation: blink 1.2s infinite;
}

@keyframes blink {
    50% { opacity: 0.2; }
}

.recorder-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1rem;
}

.record-button {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    border: 4px solid #fff;
    background: var(--danger);
    cursor: pointer;
    transition: border-radius 0.15s ease, transform 0.15s ease;
}

.record-button.is-recording {
    border-radius: 18px;
    transform: scale(0.8);
}

.progress {
    height: 6px;
    border-radius: 999px;
    background: var(--panel-2);
    overflow: hidden;
    margin-top: 1rem;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 0.2s ease;
}

.past h2 {
    margin: 1.5rem 0 0.75rem;
}

.message-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.message-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem;
    border-radius: 14px;
    background: var(--panel);
}

.message-item[data-status="pending"],
.message-item[data-status="processing"] {
    opacity: 0.6;
}

.thumb {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--panel-2);
    flex: none;
}

.thumb.placeholder.is-audio::after {
    content: "\266B";
    font-size: 1.5rem;
    color: var(--accent);
}

.empty {
    padding: 1rem 0;
}

.install-banner {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    background: var(--panel-2);
    border-bottom: 1px solid #35323f;
}

.install-banner p {
    margin: 0.15rem 0 0;
}

/* ---------- Ben's screen ---------- */

body.kiosk {
    overflow: hidden;
    user-select: none;
    cursor: none;
}

.grid-screen,
.profile-screen {
    min-height: 100vh;
    padding: 3vh 3vw 6vh;
}

.kiosk-head {
    text-align: center;
    margin-bottom: 4vh;
}

.kiosk-head h1 {
    font-size: clamp(2rem, 6vw, 4rem);
}

.kiosk-head p {
    color: var(--muted);
    font-size: clamp(1rem, 2.5vw, 1.6rem);
}

.face-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    /* Two big faces on a phone, three on the 1080px-wide wall screen. */
    grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
    gap: 4vh 4vw;
}

.face a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
}

.face-photo {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: visible;
}

.face-photo img,
.face-photo .placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    font-size: clamp(2rem, 8vw, 5rem);
}

.face.is-quiet {
    opacity: 0.45;
}

.face.is-new .face-photo {
    box-shadow: 0 0 0 8px var(--danger), 0 0 40px rgba(229, 80, 57, 0.6);
    border-radius: 50%;
    animation: bob 2.4s ease-in-out infinite;
}

@keyframes bob {
    50% { transform: translateY(-10px); }
}

.new-dot {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 2.6rem;
    height: 2.6rem;
    padding: 0 0.5rem;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 5px var(--bg);
}

.face-name {
    font-size: clamp(1.1rem, 3vw, 2rem);
    font-weight: 700;
    text-align: center;
}

.kiosk-empty {
    text-align: center;
    color: var(--muted);
    font-size: 1.5rem;
    margin-top: 20vh;
}

/* ---------- profile ---------- */

.profile-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 4vh;
}

.face-photo.big {
    width: 40vw;
    max-width: 320px;
}

.profile-head h1 {
    font-size: clamp(1.8rem, 5vw, 3rem);
}

.home-button,
.exit-button {
    position: fixed;
    top: 2vh;
    width: 4.5rem;
    height: 4.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: var(--ink);
    font-size: 2rem;
    text-decoration: none;
    z-index: 10;
    cursor: pointer;
}

.home-button {
    left: 2vw;
}

.exit-button {
    right: 2vw;
    background: rgba(255, 255, 255, 0.2);
}

.clip-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3vh 3vw;
}

.clip a {
    position: relative;
    display: block;
    aspect-ratio: 3 / 4;
    border-radius: 20px;
    overflow: hidden;
    background: var(--panel);
}

.clip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.clip-audio {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 4rem;
    color: var(--accent);
}

.clip-meta {
    position: absolute;
    bottom: 0.6rem;
    left: 0.6rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.clip.is-new a {
    box-shadow: inset 0 0 0 5px var(--danger);
}

.clip .new-dot {
    top: 0.6rem;
    right: 0.6rem;
    min-width: 1.6rem;
    height: 1.6rem;
    box-shadow: none;
}

/* ---------- player ---------- */

body.player {
    background: #000;
}

.player-screen {
    position: fixed;
    inset: 0;
    background: #000;
}

.player-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.audio-face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-face img,
.audio-face .placeholder {
    width: 60vw;
    max-width: 420px;
    aspect-ratio: 1;
    border-radius: 50%;
    object-fit: cover;
    font-size: 6rem;
}

.audio-face .pulse-ring {
    position: absolute;
    width: 60vw;
    max-width: 420px;
    aspect-ratio: 1;
    height: auto;
}

.pause-overlay,
.tap-start {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    z-index: 5;
}

.pause-icon {
    font-size: 6rem;
    color: #fff;
    opacity: 0.9;
}

.tap-start span {
    padding: 1rem 2rem;
    border-radius: 999px;
    background: var(--accent);
    color: #241b06;
    font-size: 2rem;
    font-weight: 800;
}

.player-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 10px;
    background: rgba(255, 255, 255, 0.15);
}

.player-progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
