:root {
  color-scheme: dark;
  font-family: Inter, ui-rounded, "Segoe UI", sans-serif;
  background: #10251f;
  color: #f6faf7;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: #10251f; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.pair-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.pair-panel { width: min(460px, 100%); padding: 32px; border: 1px solid #42685b; border-radius: 8px; background: #19352c; }
.brand-mark { display: grid; place-items: center; width: 64px; height: 64px; background: #f0c95f; color: #183128; border-radius: 50%; font-size: 24px; font-weight: 900; }
.pair-panel h1 { margin: 18px 0 4px; font-size: 34px; }
.pair-panel p { color: #bfd2ca; }
.pair-panel form { display: grid; gap: 10px; margin-top: 28px; }
.pair-panel label { margin-top: 8px; font-weight: 700; }
.pair-panel input { width: 100%; min-height: 54px; padding: 10px 14px; border: 1px solid #638477; border-radius: 6px; background: #10251f; color: white; }
.pair-panel .code-input { font-size: 30px; letter-spacing: .25em; text-align: center; }
.pair-panel button { min-height: 56px; margin-top: 14px; border: 0; border-radius: 6px; background: #f0c95f; color: #142820; font-weight: 900; }
.error { min-height: 24px; color: #ffb2aa !important; }

.home-view { min-height: 100vh; padding: 28px clamp(20px, 4vw, 56px) 48px; }
.home-view header { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0; color: #9bc8b5; font-size: 15px; text-transform: uppercase; }
.home-view h1 { margin: 2px 0; font-size: clamp(38px, 6vw, 72px); }
.header-tools { display: flex; align-items: center; gap: 18px; }
.clock { font-size: clamp(34px, 6vw, 68px); font-weight: 800; font-variant-numeric: tabular-nums; }
.notification-button { min-height: 50px; padding: 0 18px; border: 1px solid #86ae9d; border-radius: 6px; background: #d3e7db; color: #173027; font-weight: 900; }
.notification-button:disabled { opacity: .72; cursor: default; }
.home-view h2 { margin: 36px 0 14px; font-size: 24px; }
.event-strip { display: flex; gap: 12px; padding-bottom: 6px; overflow-x: auto; scrollbar-color: #628477 transparent; }
.event-card { flex: 0 0 220px; min-height: 108px; display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 12px; padding: 13px; border: 1px solid #496b5f; border-radius: 8px; background: #19352c; }
.event-card.birthday { border-color: #9c8444; background: #302f22; }
.event-date { display: grid; place-items: center; align-content: center; width: 58px; height: 70px; border-radius: 6px; background: #d3e7db; color: #173027; font-size: 13px; font-weight: 800; text-transform: uppercase; }
.event-date strong { font-size: 27px; line-height: 1; }
.birthday .event-date { background: #f0c95f; }
.event-copy { min-width: 0; }
.event-copy strong { display: block; overflow-wrap: anywhere; font-size: 20px; }
.event-copy small { display: block; margin-top: 5px; color: #bfd2ca; font-size: 14px; }
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.parent-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 340px)); }
.contact-card { min-height: 190px; display: grid; grid-template-columns: 72px 1fr; grid-template-rows: 1fr auto; align-items: center; gap: 12px; padding: 18px; border: 1px solid #3e6155; border-radius: 8px; background: #1a352d; }
.contact-card.is-online { border-color: #7bcf99; box-shadow: inset 0 3px 0 #7bcf99; }
.contact-card.is-online .avatar { box-shadow: 0 0 0 4px #71c78f; }
.parent-card { background: #244639; border-color: #6a927f; }
.avatar { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: #d3e7db; color: #173027; font-size: 24px; font-weight: 900; }
.contact-card strong { font-size: 25px; }
.unread { display: inline-grid; place-items: center; min-width: 30px; height: 30px; margin-left: 8px; padding: 0 7px; border-radius: 50%; background: #f0c95f; color: #10251f; font-size: 16px; }
.actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.icon-button { min-height: 58px; border: 0; border-radius: 6px; font-size: 28px; font-weight: 900; }
.call { background: #71c78f; color: #10251f; }
.message { background: #f0c95f; color: #10251f; }
.feed-form { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; gap: 10px; margin-bottom: 14px; }
.feed-form input[type="text"], #feedText { min-width: 0; min-height: 56px; padding: 0 16px; border: 1px solid #55776a; border-radius: 6px; background: #19352c; color: white; font-size: 18px; }
.family-feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); align-items: start; gap: 14px; }
.feed-empty { margin: 0; padding: 22px 0; color: #9fbbb0; }
.feed-card { position: relative; overflow: hidden; border: 1px solid #3e6155; border-radius: 8px; background: #19352c; }
.feed-card-header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.feed-card-header .avatar { width: 42px; height: 42px; font-size: 15px; }
.feed-card-header strong { display: block; font-size: 17px; }
.feed-card-header small { color: #a9c0b6; }
.feed-delete { margin-left: auto; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #304e43; color: white; font-size: 18px; }
.feed-card > p { margin: 0; padding: 0 14px 15px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 18px; }
.feed-card img, .feed-card video { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #07110d; }
.notice { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 16px 24px; border-radius: 6px; background: #f6faf7; color: #10251f; font-weight: 800; box-shadow: 0 8px 30px #0008; }

.conversation-dialog {
  width: min(920px, 92vw);
  height: min(760px, 92vh);
  padding: 0;
  border: 1px solid #577a6d;
  border-radius: 8px;
  background: #10251f;
  color: #f6faf7;
  overflow: hidden;
}
.conversation-dialog::backdrop { background: #07110dcc; backdrop-filter: blur(5px); }
.conversation-header { height: 88px; display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid #345449; background: #19352c; }
.conversation-header h2 { margin: 0; font-size: 28px; }
.close-button { width: 54px; height: 54px; border: 0; border-radius: 50%; background: #304e43; color: white; font-size: 24px; }
.small-avatar { width: 54px; height: 54px; font-size: 18px; }
.message-list { height: calc(100% - 172px); display: flex; flex-direction: column; gap: 10px; padding: 18px; overflow-y: auto; }
.message { width: fit-content; max-width: min(72%, 560px); padding: 11px 14px 7px; border-radius: 8px; background: #29483d; }
.own-message { align-self: flex-end; background: #365f4e; }
.received-message { align-self: flex-start; }
.message p { margin: 0 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 20px; }
.message small { display: block; color: #b9d0c6; text-align: right; font-size: 12px; }
.message video, .message img { display: block; width: min(520px, 100%); max-height: 420px; border-radius: 5px; object-fit: contain; background: #07110d; }
.message audio { width: min(420px, 100%); }
.message-form { height: 84px; display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; padding: 12px 16px; border-top: 1px solid #345449; background: #19352c; }
.message-form input { min-width: 0; border: 1px solid #55776a; border-radius: 6px; padding: 0 16px; background: #10251f; color: white; font-size: 19px; }
.send-button, .secondary-button, .record-button { min-height: 56px; border: 0; border-radius: 6px; padding: 0 20px; font-weight: 900; }
.send-button { background: #f0c95f; color: #10251f; }
.secondary-button { background: #38594d; color: white; }
.record-button { padding: 0; background: #df7269; color: #5b1713; font-size: 31px; }
.record-button.recording { animation: record-pulse 1s ease-in-out infinite; background: #ff9c92; }
@keyframes record-pulse { 50% { opacity: .55; } }
.recording-preview { height: calc(100% - 88px); display: grid; grid-template-rows: 1fr auto; gap: 12px; padding: 16px; background: #0b1c17; }
.recording-preview video { width: 100%; height: 100%; min-height: 0; object-fit: contain; background: black; }
.preview-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.call-dialog { width: 94vw; height: 92vh; max-width: none; max-height: none; padding: 0; border: 0; border-radius: 8px; background: #07110d; color: white; overflow: hidden; }
.call-dialog::backdrop { background: #020604ed; }
.call-stage { position: relative; width: 100%; height: 100%; background: #07110d; }
.remote-video { width: 100%; height: 100%; object-fit: contain; background: #07110d; }
.local-video { position: absolute; top: 18px; right: 18px; width: min(26vw, 290px); aspect-ratio: 4 / 3; object-fit: cover; border: 2px solid #d9e8e0; border-radius: 6px; background: #132820; }
.call-status { position: absolute; top: 24px; left: 24px; padding: 10px 14px; border-radius: 5px; background: #07110dbb; font-size: 20px; font-weight: 800; }
.incoming-call { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; background: #10251f; }
.call-avatar { width: 130px; height: 130px; font-size: 42px; }
.incoming-call h2 { margin: 0; font-size: clamp(36px, 6vw, 68px); }
.call-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 20px; }
.accept-button, .hangup-button { min-width: 150px; min-height: 64px; padding: 0 22px; border: 0; border-radius: 6px; color: white; font-size: 20px; font-weight: 900; }
.accept-button { background: #39975b; }
.hangup-button { background: #bd493f; }
.floating-hangup { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); }

.admin-dialog { width: min(980px, 94vw); height: min(820px, 92vh); padding: 0; border: 1px solid #577a6d; border-radius: 8px; background: #10251f; color: white; overflow-y: auto; }
.admin-dialog::backdrop { background: #07110ddd; }
.admin-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid #345449; background: #19352c; }
.admin-header h2 { margin: 2px 0 0; font-size: 30px; }
.admin-section { padding: 8px 22px 22px; }
.admin-section h3 { margin: 20px 0 10px; font-size: 21px; }
.admin-list { display: grid; border-top: 1px solid #345449; }
.admin-row { min-height: 68px; display: grid; grid-template-columns: minmax(150px, 1fr) minmax(160px, 1fr) auto; align-items: center; gap: 14px; padding: 10px 2px; border-bottom: 1px solid #345449; }
.admin-row p, .admin-row small { margin: 0; }
.admin-row small { color: #a9c0b6; }
.admin-action { min-height: 44px; padding: 0 14px; border: 0; border-radius: 6px; background: #f0c95f; color: #10251f; font-weight: 900; }
.admin-action.danger { background: #d97970; }
.pairing-result { grid-column: 1 / -1; padding: 12px; border: 1px solid #7bcf99; border-radius: 5px; background: #193c30; font-size: 24px; font-weight: 900; text-align: center; }
.event-form { display: grid; grid-template-columns: 2fr 1.2fr 1fr 1.2fr auto; align-items: end; gap: 12px; padding: 14px 0 18px; border-top: 1px solid #345449; }
.event-form label { display: grid; gap: 6px; color: #bfd2ca; font-size: 14px; font-weight: 700; }
.event-form input, .event-form select { width: 100%; min-height: 48px; padding: 8px 10px; border: 1px solid #55776a; border-radius: 6px; background: #10251f; color: white; }
.event-form-actions { display: flex; gap: 8px; }
.event-form-actions button { min-height: 48px; white-space: nowrap; }
.event-admin-list .admin-row { grid-template-columns: minmax(180px, 1.2fr) minmax(190px, 1fr) auto; }
.admin-row-actions { display: flex; gap: 8px; }

@media (max-width: 620px) {
  .home-view header { align-items: flex-start; }
  .header-tools { align-items: flex-end; flex-direction: column-reverse; gap: 8px; }
  .notification-button { min-height: 42px; padding: 0 12px; font-size: 14px; }
  .clock { font-size: 34px; }
  .contact-grid { grid-template-columns: 1fr 1fr; }
  .contact-card { grid-template-columns: 58px 1fr; min-height: 165px; padding: 12px; }
  .avatar { width: 58px; height: 58px; font-size: 20px; }
  .contact-card strong { font-size: 20px; }
  .feed-form { grid-template-columns: 1fr 1fr; }
  .feed-form #feedText { grid-column: 1 / -1; }
  .family-feed { grid-template-columns: 1fr; }
  .conversation-dialog { width: 96vw; height: 94vh; }
  .message { max-width: 86%; }
  .message-form { grid-template-columns: 54px 1fr 70px; padding: 10px; }
  .send-button { padding: 0 10px; }
  .local-video { width: 30vw; }
  .admin-row { grid-template-columns: 1fr auto; }
  .admin-row > :nth-child(2) { display: none; }
  .event-form { grid-template-columns: 1fr 1fr; }
  .event-form label:first-of-type, .event-form-actions { grid-column: 1 / -1; }
  .event-admin-list .admin-row { grid-template-columns: 1fr auto; }
}
