:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #d9dee5;
  --accent: #3a6df0;
  --accent-soft: #e9efff;
  --danger: #b42318;
  --shadow: 0 16px 40px rgba(24, 31, 43, 0.10);
  --phone-bg: #ffffff;
  --phone-header: #ffffff;
  --left-bubble: #e9eaee;
  --input-bg: #ffffff;
}

body.dark {
  --bg: #111318;
  --panel: #1a1e25;
  --panel-2: #20252d;
  --text: #f3f5f7;
  --muted: #aeb5bf;
  --border: #343b46;
  --accent: #6f91ff;
  --accent-soft: #26365e;
  --danger: #ff8b81;
  --shadow: 0 16px 40px rgba(0,0,0,.34);
  --phone-bg: #111317;
  --phone-header: #111317;
  --left-bubble: #2a2f37;
  --input-bg: #181c22;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background .2s ease, color .2s ease;
}

button, input, select, textarea { font: inherit; }

button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 650;
}

button:disabled { opacity: .45; cursor: default; }
button:hover:not(:disabled) { filter: brightness(.98); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
  outline-offset: 2px;
}

button.secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}

button.small { padding: 7px 10px; font-size: .9rem; }
button.wide { width: 100%; }
button.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger-outline {
  background: var(--panel);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
}

.app-shell { min-height: 100vh; }

.topbar {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: center;
  padding: 22px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { margin: 0 0 4px; font-size: 1.65rem; }
.topbar p { margin: 0; color: var(--muted); }

.top-actions, .button-row, .player-controls {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 420px) minmax(0, 1fr);
  gap: 22px;
  padding: 22px;
  align-items: start;
}

.sidebar { display: grid; gap: 16px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading h2 { margin: 0; font-size: 1.05rem; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }

label {
  display: block;
  font-size: .88rem;
  color: var(--text);
  font-weight: 600;
}

input[type="text"], input[type="time"], select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
}

textarea { resize: vertical; min-height: 90px; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.toggle-list { display: grid; gap: 8px; margin-top: 14px; }

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 500;
  color: var(--text);
}

.check input { margin: 0; }

.people-list, .saved-list, .timeline-list { display: grid; gap: 8px; }

.person-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 40px;
  gap: 7px;
  align-items: center;
}

.person-row input, .person-row select { margin: 0; }

.status {
  min-height: 20px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: .86rem;
}

.saved-item {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
}

.saved-item button {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 4px 6px;
}

.saved-item-main { min-width: 0; }
.saved-item-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-item-meta { color: var(--muted); font-size: .78rem; }

.main-stage { min-width: 0; }

.preview-actions, .player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.preview-actions span {
  color: var(--muted);
  margin-left: 8px;
  font-size: .9rem;
}

.player-bar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.speed-control select { width: auto; margin: 0; }

.preview-wrap {
  display: grid;
  place-items: start center;
  padding: 12px 0 22px;
}

.phone {
  width: min(100%, 390px);
  min-height: 720px;
  background: var(--phone-bg);
  border-radius: 38px;
  border: 9px solid #121212;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.phone-notch {
  width: 115px;
  height: 22px;
  margin: 8px auto 2px;
  border-radius: 999px;
  background: #101010;
}

.phone-header {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--phone-header);
}

.back-arrow { color: #2f6fed; font-size: 2rem; line-height: 1; margin-top: -3px; }

.info-dot {
  width: 25px;
  height: 25px;
  border: 1.5px solid #2f6fed;
  color: #2f6fed;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .8rem;
}

.phone-title-wrap { min-width: 0; text-align: center; }
.phone-title { font-weight: 700; font-size: .98rem; color: var(--text); }
.phone-members {
  margin-top: 2px;
  font-size: .71rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mock-label {
  padding: 5px 12px;
  text-align: center;
  color: var(--muted);
  font-size: .62rem;
  letter-spacing: .12em;
  border-bottom: 1px solid var(--border);
}

.message-preview {
  flex: 1;
  padding: 18px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 560px;
  scroll-behavior: smooth;
}

.message-line {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  opacity: 1;
  transform: translateY(0);
}

.message-line.entering {
  animation: messageIn .22s ease-out;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 12%, var(--panel));
  display: grid;
  place-items: center;
  font-size: .72rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.message-stack { max-width: 78%; }
.message-line.right { justify-content: flex-end; }
.message-line.right .message-stack { text-align: right; }

.sender-name {
  font-size: .68rem;
  color: var(--muted);
  margin: 0 7px 3px;
}

.bubble {
  display: inline-block;
  text-align: left;
  padding: 9px 12px;
  line-height: 1.32;
  font-size: .95rem;
  word-break: break-word;
}

.ios .left .bubble {
  background: var(--left-bubble);
  color: var(--text);
  border-radius: 18px 18px 18px 5px;
}

.ios .right .bubble {
  background: #2878f0;
  color: #fff;
  border-radius: 18px 18px 5px 18px;
}

.android .left .bubble {
  background: var(--left-bubble);
  color: var(--text);
  border-radius: 16px 16px 16px 4px;
}

.android .right .bubble {
  background: #4d73ff;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}

.generic .bubble {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 13px;
}

.generic .right .bubble { background: var(--accent-soft); }

.time-label, .read-label {
  color: var(--muted);
  font-size: .63rem;
  margin: 3px 7px 0;
}

.reaction-chip {
  display: inline-block;
  margin-top: -3px;
  padding: 1px 6px;
  font-size: .72rem;
  line-height: 1.3;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
}

.typing-dots { letter-spacing: .2em; font-weight: 800; }

.photo-placeholder {
  min-width: 170px;
  min-height: 105px;
  display: grid;
  place-items: center;
  text-align: center;
  background: color-mix(in srgb, var(--panel) 85%, var(--text));
  color: var(--muted);
  border-radius: 14px;
  padding: 14px;
}

.fake-composer {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  gap: 8px;
  align-items: center;
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border);
}

.camera-circle, .mic-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 10%, var(--panel));
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

.composer-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  font-size: .8rem;
}

.timeline-panel { margin-top: 4px; }

.timeline-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel);
}

.timeline-copy { min-width: 0; }
.timeline-who { font-size: .75rem; font-weight: 750; margin-bottom: 2px; }
.timeline-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.timeline-meta { color: var(--muted); font-size: .72rem; margin-top: 2px; }

.timeline-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.timeline-actions button {
  padding: 7px 9px;
  font-size: .82rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}

.empty { color: var(--muted); font-size: .9rem; padding: 8px 0; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .message-line.entering { animation: none; }
}

@media (max-width: 940px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: 1fr 1fr; align-items: start; }
  .preview-wrap { place-items: start center; }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; padding: 18px; flex-direction: column; }
  .workspace { padding: 14px; }
  .sidebar { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .preview-actions, .player-bar { align-items: flex-start; flex-direction: column; }
  .phone { min-height: 640px; border-width: 7px; }
  .timeline-row { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  .topbar, .sidebar, .preview-actions, .player-bar, .timeline-panel { display: none !important; }
  .workspace { display: block; padding: 0; }
  .main-stage { width: 100%; }
  .preview-wrap { padding: 0; }
  .phone {
    box-shadow: none;
    border: 0;
    border-radius: 0;
    width: 100%;
    max-width: 100%;
    min-height: auto;
  }
  .phone-notch, .fake-composer { display: none; }
}


/* ===== GLISA STYLE ===== */
.phone.glisa {
  background:
    radial-gradient(circle at 20% 15%, rgba(180, 225, 255, 0.28), transparent 24%),
    radial-gradient(circle at 80% 18%, rgba(255, 214, 245, 0.20), transparent 22%),
    radial-gradient(circle at 50% 70%, rgba(170, 255, 244, 0.14), transparent 26%),
    linear-gradient(180deg, rgba(245, 250, 255, 0.94), rgba(233, 240, 250, 0.90));
  position: relative;
}

body.dark .phone.glisa {
  background:
    radial-gradient(circle at 20% 15%, rgba(110, 168, 255, 0.25), transparent 24%),
    radial-gradient(circle at 80% 18%, rgba(196, 145, 255, 0.18), transparent 20%),
    radial-gradient(circle at 50% 70%, rgba(77, 221, 206, 0.12), transparent 26%),
    linear-gradient(180deg, rgba(16, 22, 32, 0.96), rgba(20, 28, 40, 0.93));
}

.phone.glisa::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(255,255,255,0.12), transparent 28%, rgba(255,255,255,0.08) 46%, transparent 62%),
    linear-gradient(35deg, transparent 0%, rgba(165, 227, 255, 0.14) 35%, transparent 50%, rgba(255, 196, 237, 0.11) 72%, transparent 100%);
  opacity: .9;
}

.glisa .phone-header,
.glisa .mock-label,
.glisa .fake-composer {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

body.dark .glisa .phone-header,
body.dark .glisa .mock-label,
body.dark .glisa .fake-composer {
  background: rgba(20, 28, 40, 0.34);
}

.glisa .phone-title {
  letter-spacing: .03em;
}

.glisa .message-preview {
  position: relative;
}

.glisa .message-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 7%, rgba(255,255,255,0.10) 7.5%, transparent 8%, transparent 92%, rgba(255,255,255,0.08) 92.5%, transparent 93%),
    linear-gradient(180deg, transparent 0 14%, rgba(255,255,255,0.06) 14.5%, transparent 15%, transparent 84%, rgba(255,255,255,0.05) 84.5%, transparent 85%);
  opacity: .7;
}

.glisa .avatar {
  background: rgba(255,255,255,0.42);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: 0 0 0 1px rgba(173, 216, 255, 0.25);
}

body.dark .glisa .avatar {
  background: rgba(255,255,255,0.10);
  border-color: rgba(195, 226, 255, 0.28);
}

.glisa .sender-name,
.glisa .time-label,
.glisa .read-label,
.glisa .phone-members,
.glisa .mock-label,
.glisa .composer-pill {
  color: rgba(48, 59, 84, 0.84);
}

body.dark .glisa .sender-name,
body.dark .glisa .time-label,
body.dark .glisa .read-label,
body.dark .glisa .phone-members,
body.dark .glisa .mock-label,
body.dark .glisa .composer-pill {
  color: rgba(223, 234, 255, 0.82);
}

.glisa .left .bubble,
.glisa .right .bubble {
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 10px 24px rgba(111, 141, 186, 0.10),
    inset 0 1px 0 rgba(255,255,255,0.42);
}

.glisa .left .bubble {
  background: rgba(255, 255, 255, 0.26);
  color: #38435a;
  border-bottom-left-radius: 8px;
}

.glisa .right .bubble {
  background: linear-gradient(135deg, rgba(170, 237, 255, 0.34), rgba(196, 255, 242, 0.24));
  color: #2e3e5c;
  border-bottom-right-radius: 8px;
}

body.dark .glisa .left .bubble {
  background: rgba(255,255,255,0.09);
  color: #eef5ff;
  border-color: rgba(198, 224, 255, 0.22);
}

body.dark .glisa .right .bubble {
  background: linear-gradient(135deg, rgba(73, 138, 255, 0.30), rgba(83, 211, 210, 0.18));
  color: #f3f8ff;
  border-color: rgba(172, 216, 255, 0.24);
}

.glisa .reaction-chip {
  background: rgba(255,255,255,0.34);
  border-color: rgba(255,255,255,0.52);
  box-shadow: 0 6px 14px rgba(124, 148, 181, 0.10);
}

body.dark .glisa .reaction-chip {
  background: rgba(255,255,255,0.10);
  border-color: rgba(176, 210, 255, 0.20);
}

.glisa .photo-placeholder {
  background: linear-gradient(135deg, rgba(255,255,255,0.28), rgba(208, 243, 255, 0.20));
  border: 1px solid rgba(255,255,255,0.48);
  color: rgba(56, 67, 90, 0.75);
}

body.dark .glisa .photo-placeholder {
  background: linear-gradient(135deg, rgba(255,255,255,0.07), rgba(82, 130, 190, 0.10));
  border-color: rgba(182, 212, 255, 0.18);
  color: rgba(227, 238, 255, 0.82);
}

.glisa .camera-circle,
.glisa .mic-circle {
  background: rgba(255,255,255,0.34);
  border: 1px solid rgba(255,255,255,0.48);
}

body.dark .glisa .camera-circle,
body.dark .glisa .mic-circle {
  background: rgba(255,255,255,0.08);
  border-color: rgba(190, 220, 255, 0.16);
}

.glisa .composer-pill {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.48);
}

body.dark .glisa .composer-pill {
  background: rgba(255,255,255,0.06);
  border-color: rgba(190, 220, 255, 0.16);
}
