@media (max-width: 1050px) {
  .sidebar { width: 220px; }
  .intro-art { margin-right: 0; }
  .practice-layout { grid-template-columns: 1fr; }
  .practice-preview { display: none; }
  .word-row { grid-template-columns: 1fr 1fr 105px 80px 65px; }
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #f7f7f4;
}
.login-card {
  width: min(100%, 410px);
  padding: 36px;
  border: 1px solid #ededf0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 18px 60px #30314b0d;
}
.login-icon { margin-bottom: 24px; }
.login-card h1 { margin: 12px 0 8px; font-size: 30px; letter-spacing: -.06em; }
.login-card > p { margin: 0 0 24px; color: #9293a0; font-size: 13px; line-height: 1.6; }
.login-card .form-label { margin-bottom: 8px; }
.login-card .button { width: 100%; min-height: 46px; margin-top: 16px; }
.login-card .login-error { min-height: 18px; margin: 12px 0 0; color: #b65d5d; font-size: 12px; }

@media (max-width: 750px) {
  html { scroll-padding-top: 72px; }
  body { min-width: 280px; }
  button, select, input, textarea { -webkit-tap-highlight-color: transparent; }
  .app-shell { display: block; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .sidebar {
    position: fixed; inset: auto 0 0; z-index: 8; width: 100%;
    height: auto; min-height: 0;
    padding: 7px max(12px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border: 0; border-top: 1px solid #e9e9ef; background: #fff;
    box-shadow: 0 -8px 26px #30314b0b;
  }
  .brand, .sidebar-label, .sidebar-heading, .sidebar-categories, .sidebar-bottom { display: none; }
  .main-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin: 0; }
  .nav-item {
    width: 100%; min-height: 56px; padding: 6px 3px; flex-direction: column;
    justify-content: center; gap: 2px; text-align: center; font-size: 11px; border-radius: 10px;
  }
  .nav-icon { width: auto; font-size: 22px; line-height: 25px; }
  .nav-count { display: none; }
  .topbar {
    position: sticky; top: 0; z-index: 7; height: 62px;
    padding: 0 18px; gap: 12px;
  }
  .breadcrumb { min-width: 0; font-size: 10px; letter-spacing: .08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .breadcrumb span { padding: 0 5px; }
  .topbar .button { min-height: 44px; padding: 10px 13px; flex: none; }
  .view { padding: 29px 18px 34px; }
  .page-intro { min-height: 0; padding-bottom: 28px; }
  .page-intro h1, .section-header h1 { font-size: clamp(36px, 9vw, 46px); }
  .page-intro p, .section-header p { font-size: 13px; line-height: 1.6; }
  .intro-art { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { min-height: 120px; padding: 16px; }
  .stat-card:first-child { grid-column: 1 / -1; min-height: 105px; }
  .stat-icon { width: 29px; height: 29px; margin-bottom: 7px; font-size: 16px; }
  .stat-label { font-size: 11px; }
  .stat-card strong { font-size: 29px; }
  .stat-card small { font-size: 10px; }
  .overview-grid { grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
  .daily-panel, .category-panel { min-height: 0; padding: 23px 21px; }
  .daily-panel h2 { margin-top: 20px; font-size: 22px; }
  .daily-panel p, .category-row { font-size: 12px; }
  .daily-panel .button { min-height: 44px; }
  .category-row .bar { width: 64px; }
  .section-header { margin-bottom: 23px; }
  .section-header > .button { display: none; }
  .library-panel, .practice-config { border-radius: 14px; }
  .library-toolbar { padding: 12px; flex-wrap: wrap; gap: 9px; }
  .search-box { flex: 1 0 100%; }
  .search-box input { height: 45px; font-size: 16px; }
  .library-toolbar select { flex: 1 1 140px; min-width: 0; }
  .library-toolbar .button { min-height: 44px; flex: 1 1 125px; }
  select, .form-input, textarea { font-size: 16px; }
  select { min-width: 0; min-height: 44px; }
  .word-row {
    grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px;
    padding: 17px 15px; align-items: start;
  }
  .word-term { grid-column: 1; grid-row: 1; font-size: 15px; line-height: 1.35; }
  .word-translation { grid-column: 1; grid-row: 2; font-size: 13px; line-height: 1.4; }
  .word-category { grid-column: 1; grid-row: 3; margin-top: 5px; font-size: 11px; }
  .word-status { grid-column: 1; grid-row: 4; font-size: 11px; }
  .row-actions { grid-column: 2; grid-row: 1 / 5; align-self: start; gap: 2px; }
  .row-actions button { width: 44px; height: 44px; padding: 0; font-size: 19px; }
  .practice-config { padding: 21px 18px; }
  .mode-grid { grid-template-columns: 1fr; gap: 9px; margin: 20px 0 25px; }
  .mode-card {
    min-height: 78px; padding: 12px 14px; display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    grid-template-rows: auto auto auto; column-gap: 10px; align-content: center;
  }
  .mode-icon { grid-column: 1; grid-row: 1 / 4; align-self: center; margin: 0; font-size: 23px; }
  .mode-card strong { grid-column: 2; grid-row: 1; font-size: 13px; }
  .mode-card small { grid-column: 2; grid-row: 2; margin: 3px 0; font-size: 11px; }
  .mode-count { grid-column: 2; grid-row: 3; margin: 0; font-size: 10px; }
  .field-row { grid-template-columns: 1fr; gap: 15px; }
  .button-large { width: 100%; min-height: 48px; }
  .practice-session, .practice-finish { margin-top: 4px; }
  .session-exit { min-height: 44px; padding: 0 8px 0 0; font-size: 12px; }
  .session-top { margin-bottom: 14px; }
  .flashcard { min-height: min(43vh, 330px); padding: 25px 18px; }
  .flashcard .flash-term { font-size: clamp(30px, 8vw, 44px); }
  .answer-actions .button { min-height: 50px; }
  .finish-box { padding: 34px 18px; }
  .finish-actions .button { min-height: 44px; }
  .modal, .modal-small {
    position: fixed; inset: auto 0 0; width: 100%; max-width: 100%;
    max-height: calc(100dvh - 12px); margin: 0; border-radius: 20px 20px 0 0;
  }
  .modal-inner { padding: 23px 18px calc(22px + env(safe-area-inset-bottom)); }
  .modal-close { width: 44px; height: 44px; flex: none; font-size: 22px; }
  .modal-header { gap: 12px; }
  .modal-header h2 { font-size: 23px; }
  .tab { min-height: 44px; font-size: 12px; }
  .form-actions { margin-top: 18px; }
  .form-actions .button { min-height: 44px; flex: 1; }
  .file-row { flex-wrap: wrap; }
  .file-label { min-height: 44px; display: inline-flex; align-items: center; }
  .category-manage-row { flex-wrap: wrap; }
  .category-manage-row strong { min-width: 45%; overflow-wrap: anywhere; }
  .category-manage-row button { min-height: 40px; }
  .toast {
    left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom));
    max-width: none; text-align: center; font-size: 12px;
  }
  .login-card { padding: 28px 22px; }
}

@media (max-width: 390px) {
  .topbar .button { width: 44px; padding: 0; font-size: 0; gap: 0; }
  .topbar .button span { font-size: 20px; }
  .view { padding-left: 14px; padding-right: 14px; }
  .row-actions button { width: 40px; }
  .answer-actions, .finish-actions { flex-direction: column; }
}

