/* Shared base ------------------------------------------------------------ */

:root {
  --font-stack:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* ,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  margin: 0;
  background: #16323c;
}

body {
  margin: 0;
}

/* Fills the iOS safe-area inset (notch/status-bar strip) with the brand navy so an
   installed PWA's black-translucent status bar reads navy instead of the page
   background showing through. A no-op everywhere else, since the inset is 0. */
.status-bar-fill {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-top, 0px);
  background: #16323c;
  z-index: 9999;
  pointer-events: none;
}

/* Reserves space for the window controls overlay's right-aligned title bar buttons
   (Windows/Linux/ChromeOS) so content isn't hidden underneath them, and makes that
   strip draggable. Mac's left-aligned traffic lights are handled by .sidebar instead.
   env(titlebar-area-height) is 0 unless the overlay is active. */
.titlebar-fill {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: env(titlebar-area-height, 0px);
  background: #16323c;
  z-index: 9999;
  -webkit-app-region: drag;
  app-region: drag;
}

:root[data-platform='mac'] .titlebar-fill {
  display: none;
}

/* Signed-out page shell (light/dark aware) --------------------------------- */

.page {
  --surface-0: #f3f5f7;
  --surface-1: #ffffff;
  --surface-2: #eef1f4;
  --text-primary: #1c2024;
  --text-secondary: #5b6470;
  --brand-primary: #16323c;
  --brand-primary-hover: #0f242c;
  --border: #dde2e7;
  --error: #b3261e;
  --error-bg: #fbeae9;
  --notice-bg: #eaf1f3;

  margin: 0;
  padding: 48px 20px;
  min-height: 100vh;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--font-stack);
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  justify-content: center;
}

@media (prefers-color-scheme: dark) {
  .page {
    --surface-0: #15181b;
    --surface-1: #1e2226;
    --surface-2: #25292e;
    --text-primary: #eef1f4;
    --text-secondary: #9aa4af;
    --brand-primary: #3f6b7d;
    --brand-primary-hover: #4a7d90;
    --border: #2e3338;
    --error: #ff8983;
    --error-bg: #3a1f1e;
    --notice-bg: #1c272e;
  }
}

.card {
  width: 100%;
  max-width: 480px;
  height: fit-content;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card-wide {
  max-width: 760px;
}

.title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.lead {
  margin: 0;
  color: var(--text-secondary);
}

.button {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: #ffffff;
  background: var(--brand-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.button:hover,
.button:focus-visible {
  background: var(--brand-primary-hover);
  outline: none;
}

/* Signed-in app shell (fixed navy/white) ----------------------------------- */

.shell {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  width: 100%;
  height: 100vh;
  background: #16323c;
  font-family: var(--font-stack);
  font-size: 15px;
  line-height: 1.5;
}

@media (display-mode: window-controls-overlay) {
  :root:not([data-platform='mac']) .shell {
    padding-top: calc(16px + env(titlebar-area-height, 0px));
  }
}

.sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  align-self: stretch;
  width: 41px;
  flex-shrink: 0;
  gap: 16px;
}

@media (display-mode: window-controls-overlay) {
  :root[data-platform='mac'] .sidebar {
    width: max(42px, env(titlebar-area-x, 42px));
    padding-top: env(titlebar-area-height, 28px);
    -webkit-app-region: drag;
    app-region: drag;
  }
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: stretch;
  gap: 8px;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: stretch;
  gap: 13px;
}

.logo {
  align-self: stretch;
  height: 46px;
  flex-shrink: 0;
  object-fit: cover;
}

.icon-link {
  display: flex;
  flex-shrink: 0;
  padding: 4px;
  border-radius: 8px;
  color: #ffffff;
  text-decoration: none;
  cursor: pointer;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

.icon-link-active {
  background: rgba(255, 255, 255, 0.16);
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 9999px;
  overflow: hidden;
  background: #ffffff;
  color: #000000;
  font-size: 16px;
  line-height: 20px;
  text-decoration: none;
  cursor: pointer;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.content {
  flex: 1 1 0%;
  align-self: stretch;
  border-radius: 14px;
  background: #ffffff;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.content-padded {
  padding: 48px;
}

.center-column {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 640px;
  width: 100%;
}

.content-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #16323c;
}

.content-text {
  margin: 0;
  font-size: 16px;
  line-height: 20px;
  color: #000000;
}

.content-muted {
  margin: 0;
  font-size: 14px;
  color: #5b6470;
}

.notebook-iframe {
  border: 0;
  width: 100%;
  height: 100%;
  flex: 1;
}

/* Buttons, forms, tables shared by both shells ----------------------------- */

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

.primary-button,
.secondary-button,
.danger-button,
.link-button,
.danger-link-button {
  appearance: none;
  border-radius: 5px;
  padding: 10px 15px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.primary-button {
  border: 0;
  font-size: 16px;
  color: #ffffff;
  background: #16323c;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: #0f242c;
  outline: none;
}

.secondary-button {
  border: 1px solid #dde2e7;
  color: #16323c;
  background: transparent;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: #eef1f4;
  outline: none;
}

.danger-button {
  border: 1px solid #b3261e;
  color: #b3261e;
  background: transparent;
}

.danger-button:hover,
.danger-button:focus-visible {
  background: #fbeae9;
  outline: none;
}

.link-button {
  border: 1px solid var(--border);
  color: var(--text-primary);
  background: transparent;
}

.link-button:hover,
.link-button:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.danger-link-button {
  border: 1px solid var(--error);
  color: var(--error);
  background: transparent;
}

.danger-link-button:hover,
.danger-link-button:focus-visible {
  background: var(--error-bg);
  outline: none;
}

.error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fbeae9;
  color: #b3261e;
  font-size: 14px;
}

.content-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fbeae9;
  color: #b3261e;
  font-size: 14px;
}

.notice {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef1f4;
  color: #16323c;
  font-size: 14px;
}

.badge {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #16323c;
  color: #ffffff;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid #dde2e7;
}

.table th {
  color: #5b6470;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.input {
  appearance: none;
  border: 1px solid #dde2e7;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  color: #000000;
  background: #ffffff;
}

.input:focus-visible {
  outline: 2px solid #16323c;
  outline-offset: -1px;
}

/* Settings page cards ------------------------------------------------------ */

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid #dde2e7;
}

.settings-card:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 9999px;
  overflow: hidden;
  background: #16323c;
  color: #ffffff;
  font-size: 20px;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
