/* Tokens come from design-system.css loaded before this file */

/* Perkins-specific surface tokens */
:root {
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 255, 255, 0.98);
  --dot-bg: rgba(226, 232, 240, 0.9);
  --perkins-braille-font-size: 16px;
  --perkins-braille-letter-spacing: 0.08em;
  --btn-secondary-bg: var(--btn-secondary-bg, #F1F5F9);
  --status-ok: var(--ok);
  --status-error: var(--danger);
}

:root[data-theme="dark"] {
  --surface: rgba(15, 23, 42, 0.85);
  --surface-strong: rgba(15, 23, 42, 0.9);
  --dot-bg: rgba(15, 23, 42, 0.65);
  --status-ok: var(--ok);
  --status-error: var(--danger);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  background-image: var(--bg-gradient), var(--bg-texture);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 220;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 14px;
}

.skip-link:focus {
  top: 12px;
}

body.perkins-help-open {
  overflow: hidden;
}

.startup-splash {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 16% 12%, rgba(59, 91, 219, 0.12), transparent 42%),
    radial-gradient(circle at 82% 8%, rgba(37, 99, 235, 0.24), transparent 38%),
    rgba(2, 6, 23, 0.86);
  backdrop-filter: blur(8px);
}

.startup-splash-card {
  width: min(420px, calc(100vw - 36px));
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(170deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.9));
  padding: 28px 24px 24px;
  text-align: center;
  box-shadow: 0 24px 40px rgba(2, 6, 23, 0.6);
}

.startup-splash-logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  align-items: center;
  justify-items: center;
  background: var(--accent);
  border-radius: 12px;
  padding: 9px;
}

.startup-splash-logo .dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
}

.startup-splash-logo .dot.on {
  background: #ffffff;
}

.startup-splash-card h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 33px);
}

.startup-splash-card p {
  margin: 12px 0 0;
  color: var(--muted);
  font-family: var(--font-ui);
}

.startup-splash-loader {
  margin: 18px auto 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(148, 163, 184, 0.35);
  border-top-color: var(--accent);
  animation: startup-spin 860ms linear infinite;
}

.auth-user-badge {
  max-width: 250px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

code {
  padding: 0.1rem 0.35rem;
  border-radius: 0.35rem;
  background: rgba(148, 163, 184, 0.2);
  font-family: var(--font-ui);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 42px;
  height: 42px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  align-items: center;
  justify-items: center;
  background: var(--accent);
  padding: 8px;
  border-radius: 10px;
}

.logo .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
}

.logo .dot.on {
  background: #ffffff;
}

.title h1 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 19px;
}

.title p {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 13px;
}

.app-body > main.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 16px 28px;
}

.workspace {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.workspace-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 10px;
  align-items: end;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font-ui);
}

select,
textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

#brailleBuffer {
  font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", "DejaVu Sans", var(--font-body);
  font-size: var(--perkins-braille-font-size);
  letter-spacing: var(--perkins-braille-letter-spacing);
  line-height: 1.75;
  caret-color: var(--accent);
  height: 132px;
  min-height: 132px;
  max-height: 132px;
  overflow-y: auto;
  resize: none;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  font-family: var(--font-ui);
  min-height: 45px;
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.meta {
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font-ui);
}

.status {
  margin: 0 0 6px;
  min-height: 20px;
  color: var(--status-ok);
  font-family: var(--font-ui);
}

.status.error {
  color: var(--status-error);
}

.user-error-popup {
  position: fixed;
  z-index: 220;
  top: 16px;
  right: 16px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}

.user-error-popup-card {
  pointer-events: auto;
  border: 1px solid var(--panel-border);
  border-left: 4px solid var(--danger);
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
  padding: 12px 12px 10px;
  display: grid;
  gap: 8px;
}

.user-error-popup-title {
  font-family: var(--font-ui);
  color: var(--danger);
}

.user-error-popup-message {
  margin: 0;
  color: var(--text);
  font-family: var(--font-ui);
}

.user-error-popup-close {
  justify-self: end;
}

.user-success-popup {
  position: fixed;
  z-index: 220;
  top: 16px;
  right: 16px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}

.user-success-popup-card {
  pointer-events: auto;
  border: 1px solid var(--panel-border);
  border-left: 4px solid var(--ok);
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.user-success-popup-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-success-popup-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: var(--ok);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1;
  animation: submission-pop 280ms ease-out;
}

.user-success-popup-title {
  color: var(--ok);
  font-family: var(--font-ui);
}

.user-success-popup-message {
  margin: 0;
  color: var(--text);
  font-family: var(--font-ui);
}

.user-success-popup-close {
  justify-self: end;
}

.submission-confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 230;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(3px);
}

.submission-confirm-card {
  width: min(420px, calc(100vw - 24px));
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  display: grid;
  gap: 10px;
}

.submission-confirm-title {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
}

.submission-confirm-message {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
}

.submission-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.perkins-help-dialog {
  position: fixed;
  inset: 0;
  z-index: 235;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(3px);
}

.perkins-help-card {
  width: min(760px, calc(100vw - 20px));
  max-height: min(90vh, 860px);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
}

.perkins-help-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.perkins-help-eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.perkins-help-head h2 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 20px;
}

.perkins-help-support {
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--panel-border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 86%, var(--accent) 14%);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.perkins-help-support-channels {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--panel-border) 85%, transparent 15%);
  background: color-mix(in srgb, var(--surface) 91%, var(--accent) 9%);
  display: grid;
  gap: 8px;
}

.perkins-help-support-label {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.perkins-help-support-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 46%, transparent 54%) transparent;
}

.perkins-help-support-actions::-webkit-scrollbar {
  height: 6px;
}

.perkins-help-support-actions::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent) 52%, transparent 48%);
  border-radius: 999px;
}

.perkins-help-support-action {
  flex: 1 1 0;
  min-width: 118px;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

.perkins-help-intro {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.perkins-help-content {
  overflow-y: auto;
  padding: 2px 4px 2px 0;
  display: grid;
  gap: 10px;
}

.perkins-help-section {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
  padding: 10px 10px 8px;
}

.perkins-help-section h3 {
  margin: 0 0 6px;
  font-family: var(--font-ui);
  font-size: 14px;
}

.perkins-help-section ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
}

.perkins-help-section li {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.perkins-help-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.perkins-help-section-actions {
  position: sticky;
  bottom: 0;
  background: color-mix(in srgb, var(--surface-strong) 92%, var(--accent) 8%);
  box-shadow: 0 -10px 18px rgba(15, 23, 42, 0.08);
}

.perkins-help-section-actions h3 {
  margin-bottom: 8px;
}

@keyframes submission-pop {
  0% {
    transform: scale(0.68);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.mode-tabs {
  margin-top: 10px;
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid var(--panel-border);
  border-radius: 9px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.78);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 15px;
}

.tab.active {
  background: var(--accent);
  border-color: transparent;
}

.panel {
  margin-top: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--surface);
  padding: 14px;
}

.panel.hidden {
  display: none;
}

.panel h2 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 18px;
}

.panel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.dot-grid-wrap {
  margin-top: 8px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--surface-strong);
  padding: 8px 10px;
  display: inline-grid;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  font-size: 12px;
}

.dot-grid-label {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.25;
}

.dot-grid {
  margin-top: 4px;
  width: 72px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 8px;
}

.dot-cell {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: var(--dot-bg);
}

.dot-cell.active {
  background: var(--accent);
  border-color: var(--accent);
}

#chordPreview {
  margin: 0;
  font-size: 12px;
  line-height: 1.25;
}

.action-row {
  margin: 10px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.export-row {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--panel-border);
}

.export-row .hint {
  margin: 0 0 8px;
}

.export-actions {
  margin: 0;
}

.sessions-tab {
  margin-top: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--surface-strong);
  overflow: hidden;
}

.sessions-tab > summary {
  cursor: pointer;
  padding: 10px 12px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}

.sessions-tab > summary::-webkit-details-marker {
  display: none;
}

.sessions-tab > summary::after {
  content: "▾";
  float: right;
  color: var(--muted);
}

.sessions-tab:not([open]) > summary::after {
  content: "▸";
}

.sessions-tab[open] > summary {
  border-bottom: 1px solid var(--panel-border);
}

.sessions-shell {
  padding: 10px 12px 12px;
}

.sessions-shell .hint {
  margin: 0 0 8px;
}

.sessions-tools {
  margin: 0 0 8px;
}

.session-status {
  min-height: 20px;
}

.session-status.error {
  color: var(--status-error);
}

.session-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.session-item {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--surface);
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.session-title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
}

.session-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.session-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.session-actions .btn {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.session-empty {
  margin: 0;
  padding: 10px;
  border: 1px dashed var(--panel-border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 12px;
  min-height: 40px;
  background: var(--accent-2);
  color: #ffffff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14px;
}

.btn.primary {
  background: var(--accent);
  color: var(--btn-primary-text);
}

.btn.secondary {
  background: var(--btn-secondary-bg);
  color: var(--text);
  border-color: var(--panel-border);
}

.btn.ghost {
  background: transparent;
  border-color: var(--panel-border);
  color: var(--muted);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:focus-visible,
.tab:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 1040px) {
  .workspace-controls {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

  .topbar {
    flex-wrap: wrap;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    padding: 12px 14px;
  }

  .header-controls {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .panel-row {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-row .btn {
    width: 100%;
  }

  .perkins-help-card {
    width: min(760px, calc(100vw - 14px));
    max-height: 92vh;
    padding: 12px;
  }

  .perkins-help-head {
    flex-direction: column;
    align-items: stretch;
  }

  .perkins-help-actions .btn {
    width: 100%;
    min-height: 42px;
  }

  .workspace-controls {
    grid-template-columns: 1fr;
  }

  .action-row .btn {
    flex: 1 1 calc(50% - 8px);
    min-height: 44px;
  }

  .export-actions .btn {
    flex: 1 1 100%;
  }
}

@media (max-width: 560px) {
  .app-body > main.app-shell {
    padding: 14px 12px 22px;
  }

  .workspace {
    padding: 12px;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .action-row .btn {
    width: 100%;
  }

  .submission-confirm-actions .btn {
    width: 100%;
  }

  .perkins-help-dialog {
    padding: 10px;
  }

  .perkins-help-card {
    border-radius: 12px;
  }

  /* Session action buttons: raise to 44px touch target minimum */
  .session-actions .btn {
    min-height: 44px;
    padding: 8px 12px;
  }
}

@keyframes startup-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
