:root {
  --bg: #f3eee6;
  --glass: rgba(255, 255, 255, 0.78);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --nav-glass: rgba(255, 255, 255, 0.55);
  --nav-glass-scrolled: rgba(255, 255, 255, 0.38);
  --glass-border: rgba(0, 0, 0, 0.08);
  --text: #3a322b;
  --text-secondary: #7a6e64;
  --accent: #3a3532;
  --accent-hover: #2a2624;
  --accent-soft: rgba(58, 53, 50, 0.1);
  --btn-primary-text: #fff;
  --input-bg: rgba(255, 255, 255, 0.55);
  --input-bg-focus: rgba(255, 255, 255, 0.72);
  --btn-secondary-bg: rgba(255, 250, 244, 0.42);
  --btn-ghost-bg: rgba(255, 255, 255, 0.28);
  --avatar-bg: rgba(255, 250, 244, 0.55);
  --orb-a: rgba(232, 214, 190, 0.35);
  --orb-b: rgba(236, 196, 168, 0.22);
  --orb-c: rgba(214, 196, 176, 0.28);
  --border: rgba(58, 50, 43, 0.08);
  --shadow-glass: 0 8px 30px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  --shadow-lift: 0 12px 36px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --radius: 22px;
  --radius-sm: 14px;
  --font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  --error: #d70015;
  --panel: rgba(255, 252, 248, 0.97);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #1c1916;
  --glass: rgba(48, 44, 40, 0.78);
  --glass-strong: rgba(58, 54, 50, 0.9);
  --nav-glass: rgba(28, 25, 22, 0.5);
  --nav-glass-scrolled: rgba(28, 25, 22, 0.32);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text: #f3eee6;
  --text-secondary: #b8aea4;
  --accent: #f3eee6;
  --accent-hover: #e4d9cc;
  --accent-soft: rgba(243, 238, 230, 0.12);
  --btn-primary-text: #1c1916;
  --input-bg: rgba(255, 255, 255, 0.06);
  --input-bg-focus: rgba(255, 255, 255, 0.1);
  --btn-secondary-bg: rgba(255, 255, 255, 0.06);
  --btn-ghost-bg: rgba(255, 255, 255, 0.06);
  --avatar-bg: rgba(255, 255, 255, 0.08);
  --orb-a: rgba(120, 96, 72, 0.28);
  --orb-b: rgba(140, 100, 70, 0.18);
  --orb-c: rgba(90, 78, 68, 0.3);
  --border: rgba(255, 255, 255, 0.08);
  --shadow-glass: 0 8px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-lift: 0 12px 36px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --error: #ff6b6b;
  --panel: rgba(42, 38, 34, 0.97);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.7;
}

.orb-a {
  width: 420px;
  height: 420px;
  top: 42%;
  left: -140px;
  background: var(--orb-a);
}

.orb-b {
  width: 360px;
  height: 360px;
  top: 58%;
  right: -140px;
  background: var(--orb-b);
}

.orb-c {
  width: 480px;
  height: 480px;
  bottom: -220px;
  left: 28%;
  background: var(--orb-c);
}

/* Topbar */
.topbar {
  position: fixed;
  top: 12px;
  left: 18px;
  right: 18px;
  z-index: 50;
  box-sizing: border-box;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: var(--nav-glass);
  box-shadow: var(--shadow-glass);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  transition: background 0.2s ease, backdrop-filter 0.2s ease, box-shadow 0.2s ease;
}

.topbar.is-scrolled {
  background: var(--nav-glass-scrolled);
  backdrop-filter: saturate(190%) blur(28px);
  -webkit-backdrop-filter: saturate(190%) blur(28px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: contain;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--glass-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-title {
  font-weight: 600;
  font-size: 15px;
}

.brand-subtitle {
  color: var(--text-secondary);
  font-size: 12px;
}

/* Layout */
.wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 140px 24px 64px;
}

.foot {
  position: relative;
  z-index: 1;
  padding: 20px 28px 28px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
}

.foot a {
  color: var(--text-secondary);
  text-decoration: none;
}

.foot a:hover {
  color: var(--accent);
}

/* Cards */
.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass);
  padding: 28px;
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
}

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

/* Login */
.login-card {
  max-width: 400px;
  margin: 48px auto 0;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 22px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field input {
  font-family: inherit;
  font-size: 14px;
  padding: 11px 13px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--input-bg-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Flash */
.flash {
  max-width: 400px;
  margin: 0 auto 18px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(215, 0, 21, 0.08);
  border: 1px solid rgba(215, 0, 21, 0.22);
  color: var(--error);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.flash p {
  margin: 0;
}

/* Portal */
.portal-head {
  margin-bottom: 32px;
}

.portal-head h1 {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: #fff;
  color: #3a322b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}

.theme-toggle:hover {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.theme-toggle svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

.profile-menu {
  position: relative;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  line-height: 0;
  font-size: 0;
}

.profile-btn:hover .client-avatar,
.profile-btn[aria-expanded="true"] .client-avatar {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.client-avatar {
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: contain;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--glass-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  display: block;
  vertical-align: top;
}

.client-avatar--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
  color: #3a322b;
  background: #efe8dc;
}

.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  box-shadow: var(--shadow-lift);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  z-index: 60;
}

.profile-dropdown-name {
  margin: 0;
  padding: 10px 12px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.profile-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.profile-dropdown-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-dropdown-item:hover {
  background: var(--accent-soft);
}

.empty {
  margin-top: 40px;
  text-align: center;
}

.cards {
  display: grid;
  gap: 18px;
}

.analysis-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.analysis-card:hover {
  transform: translateY(-2px);
  background: var(--glass-strong);
  box-shadow: var(--shadow-lift);
}

.analysis-card h2 {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.analysis-card .topic {
  margin: 0 0 18px;
  font-size: 13px;
}

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

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-ghost {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 42%), var(--accent);
  color: var(--btn-primary-text);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 42%), var(--accent-hover);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--accent);
  border-color: var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-secondary:hover {
  background: var(--accent-soft);
}

.btn-ghost {
  background: var(--btn-ghost-bg);
  color: var(--text-secondary);
  border-color: var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--accent);
}

.btn-primary:active,
.btn-secondary:active,
.btn-ghost:active {
  transform: scale(0.98);
}

.login-card .btn-primary {
  margin-top: 4px;
  width: 100%;
  padding: 12px;
}

.logout-form {
  margin: 0;
}

.updates-menu {
  position: relative;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.updates-btn {
  box-sizing: border-box;
  position: relative;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: #fff;
  color: #3a322b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}

.updates-btn:hover,
.updates-btn[aria-expanded="true"] {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.updates-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.updates-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

.updates-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 360px;
  max-width: calc(100vw - 36px);
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--panel);
  box-shadow: var(--shadow-lift);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  z-index: 60;
}

.updates-panel-head {
  padding: 10px 12px 8px;
}

.updates-panel-head h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.updates-panel-head .muted {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

.updates-empty {
  margin: 8px 12px 12px;
}

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

.updates-item {
  padding: 12px;
  border-top: 1px solid var(--glass-border);
}

.updates-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.updates-item-meta time {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.updates-new {
  display: none;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--error);
}

.updates-item.is-new .updates-new {
  display: inline;
}

.updates-item h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.updates-item-analysis {
  margin: 6px 6px 0 0;
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 8px;
}

.updates-item-body {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* PDF viewer */
.viewer-body {
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.viewer-body::before {
  display: none;
}

.viewer-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-strong);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
}

.viewer-title {
  flex: 1;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-frame {
  flex: 1;
  width: 100%;
  border: 0;
}

/* Transcript */
.transcript {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .topbar {
    top: 8px;
    left: 10px;
    right: 10px;
    height: 72px;
    padding: 0 14px;
  }

  .wrap {
    padding-top: 128px;
  }

  .portal-head h1 {
    font-size: 24px;
  }

  .updates-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    top: 92px;
    width: auto;
    max-width: none;
  }
}
