/* Phase 2 shared UI foundation ------------------------------------------------
   These patterns intentionally sit at the end of the route stylesheet so new
   and migrated workspace screens share one accessible visual language. */
.portal-layout {
  --ui-border: #d8e4f3;
  --ui-border-strong: #b8cdea;
  --ui-focus: #1267ed;
  --ui-radius-control: 11px;
  --ui-radius-panel: 18px;
  --ui-shadow-panel: 0 12px 32px rgba(28, 67, 116, .08);
}

.workspace-page-header {
  align-items: center;
  gap: clamp(16px, 3vw, 34px);
}

.workspace-page-header-copy { min-width: 0; }
.workspace-page-header-copy > :last-child { max-width: 70ch; }
.workspace-page-header-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.portal-notice {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 11px 12px;
  border: 1px solid #b9d4f4;
  border-radius: 13px;
  color: #174c83;
  background: #eff7ff;
  box-shadow: 0 8px 22px rgba(42, 85, 137, .07);
  font-size: .82rem;
  line-height: 1.45;
}
.portal-notice-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #2877d8;
  font-size: .78rem;
  font-weight: 900;
}
.portal-notice-copy { min-width: 0; }
.portal-notice-copy > strong { display: block; margin-bottom: 2px; color: inherit; }
.portal-notice-success { border-color: #8fd7b9; color: #075d48; background: #edfbf4; }
.portal-notice-success .portal-notice-icon { background: #0f946d; }
.portal-notice-warning { border-color: #e6c274; color: #795000; background: #fff8e7; }
.portal-notice-warning .portal-notice-icon { background: #c48200; }
.portal-notice-error { border-color: #eca4ad; color: #922635; background: #fff1f3; }
.portal-notice-error .portal-notice-icon { background: #cf4051; }
.portal-notice-dismiss {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: currentColor;
  background: transparent;
  cursor: pointer;
  font: 800 1.15rem/1 Arial, sans-serif;
}
.portal-notice-dismiss:hover { background: rgba(20, 62, 112, .08); }

.status-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border: 1px solid #d7e2ef;
  border-radius: 999px;
  color: #425b7d;
  background: #f4f7fb;
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .025em;
  line-height: 1;
  white-space: nowrap;
}
.status-pill-info { border-color: #b9d4f5; color: #145db4; background: #eef6ff; }
.status-pill-success, .status-pill.success { border-color: #95d7bb; color: #087455; background: #edf9f3; }
.status-pill-warning { border-color: #e8c578; color: #885a00; background: #fff7e3; }
.status-pill-danger { border-color: #eea6af; color: #a02636; background: #fff0f2; }

.field-feedback {
  display: block;
  margin-top: 4px;
  color: #617794;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.4;
}
.field-feedback-error { color: #b52638; }
.field-feedback-success { color: #087455; }

.portal-main :where(a, button, input, select, textarea, summary):focus-visible,
.mobile-nav-checkbox:focus-visible + .mobile-nav-toggle,
.mobile-nav-toggle:focus-visible,
.mobile-nav-backdrop:focus-visible {
  outline: 3px solid rgba(18, 103, 237, .32);
  outline-offset: 2px;
}
.portal-main :where(input, select, textarea) {
  border-radius: var(--ui-radius-control, 11px);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.portal-main :where(input, select, textarea):focus {
  border-color: var(--ui-focus, #1267ed);
  box-shadow: 0 0 0 3px rgba(18, 103, 237, .1);
}
.sidebar-nav a[aria-current="page"] { position: relative; }
.sidebar-nav a[aria-current="page"]::after {
  position: absolute;
  top: 50%;
  right: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  opacity: .7;
  transform: translateY(-50%);
}
.mobile-nav-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}
.mobile-nav-checkbox {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.mobile-nav-backdrop { display: none; padding: 0; border: 0; background: transparent; }

.workspace-service-banner {
  position: fixed;
  z-index: 220;
  top: 10px;
  left: 50%;
  display: flex;
  width: min(720px, calc(100vw - 24px));
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid #e4b54d;
  border-radius: 12px;
  color: #6f4200;
  background: #fff5d6;
  box-shadow: 0 12px 30px rgba(41, 62, 95, .18);
  font-size: .82rem;
  transform: translateX(-50%);
}
.workspace-service-banner.offline { border-color: #e59aa5; color: #8b1f32; background: #fff0f2; }
.workspace-service-banner span { line-height: 1.35; }
.workspace-empty-state {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 96px;
  padding: 18px;
  border: 1px dashed #bfd1e8;
  border-radius: 15px;
  color: #395879;
  background: #f8fbff;
}
.workspace-empty-state > span { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; background: #e7f1ff; font-size: 1.4rem; }
.workspace-empty-state strong { color: #10264c; }
.workspace-empty-state p { margin: 4px 0 0; }
.portal-notice-action { margin-top: 8px; }
.portal-notice-action form { margin: 0; }
.portal-notice-action-button { padding: 6px 10px; border: 1px solid currentColor; border-radius: 8px; color: inherit; background: rgba(255,255,255,.64); font: inherit; font-weight: 800; cursor: pointer; }
.editor-save-state { display: inline-flex; align-items: center; color: #52708f; font-size: .74rem; font-weight: 800; white-space: nowrap; }
.editor-save-state::before { width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #18a77d; content: ""; }
.editor-save-state.unsaved { color: #8b5700; }
.editor-save-state.unsaved::before { background: #e4a11b; }
.writing-autosave-state { font-weight: 700; }
.writing-autosave-state.saving { color: #315f9c; }
.writing-autosave-state.saved { color: #087455; }
.writing-autosave-state.offline,
.writing-autosave-state.error { color: #a1283d; }
.homework-card { scroll-margin-top: 18px; }

@media (max-width: 760px) {
  .workspace-service-banner { top: 62px; align-items: flex-start; flex-direction: column; gap: 2px; }
  .workspace-empty-state { grid-template-columns: 36px minmax(0, 1fr); }
  .workspace-empty-action { grid-column: 1 / -1; }
  .workspace-page-header { align-items: flex-start; }
  .workspace-page-header-actions { width: 100%; justify-content: flex-start; }
  .workspace-page-header-actions > * { max-width: 100%; }
  .portal-notice { grid-template-columns: 28px minmax(0, 1fr) 30px; }
  .mobile-nav-checkbox:checked ~ .mobile-nav-backdrop {
    position: fixed;
    z-index: 145;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(6, 29, 65, .42);
    backdrop-filter: blur(2px);
  }

  .mobile-nav-toggle {
    position: fixed;
    z-index: 160;
    top: 14px;
    right: 14px;
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: 1px solid #0b56d6;
    border-radius: 12px;
    color: #fff;
    background: #1165ed;
    box-shadow: 0 8px 24px rgba(37, 99, 235, .24);
    font-weight: 800;
  }
  .mobile-nav-checkbox:not(:checked) ~ .portal-sidebar { display: none !important; }
  .mobile-nav-checkbox:checked ~ .portal-sidebar {
    position: fixed !important;
    z-index: 150;
    inset: 10px;
    display: flex !important;
    width: auto !important;
    min-height: 0 !important;
    margin: 0;
    overflow-y: auto;
    padding: 70px 16px 16px;
  }
  .mobile-nav-checkbox:checked + .mobile-nav-toggle svg { transform: rotate(90deg); }

  .student-grammar-view-toggle { display: none !important; }
  .grammar-prototype-heading { padding-top: 56px; }
  .grammar-level-picker { gap: 6px; }
  .grammar-level-picker button { min-width: 46px; min-height: 42px; padding: 7px 10px; }
  .grammar-level-picker button small { display: none; }
  .grammar-tour-coach {
    left: var(--grammar-tour-left, 12px) !important;
    top: var(--grammar-tour-top, 16px) !important;
    bottom: auto !important;
    width: min(340px, calc(100vw - 24px)) !important;
    padding: 18px !important;
  }
  .grammar-tour-coach h2 { font-size: 1.1rem; }
  .grammar-tour-coach p { font-size: .92rem; }
  .grammar-tour-arrow { display: block !important; }
  .placement-module-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; overflow: visible !important; }
}
