.mobile-library-action {
  display: none;
}

.mobile-header-search {
  display: none;
}

@media (max-width: 700px) {
  html,
  body,
  .app-shell {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  body {
    background: var(--bg);
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
  }

  .app-shell {
    grid-template-rows: minmax(0, 1fr) auto;
    background: var(--bg);
  }

  .workspace,
  .app-shell[data-file-panel="collapsed"] .workspace,
  .app-shell[data-mobile-screen="detail"] .workspace {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    padding: 0;
    overflow: hidden;
    background: var(--bg);
  }

  .app-shell[data-mobile-screen="list"] .workspace {
    grid-template-rows: minmax(0, 1fr);
  }

  .file-panel-resizer,
  .splitter {
    display: none !important;
  }

  .app-shell[data-mobile-screen="detail"] .file-panel {
    display: none !important;
  }

  .app-shell[data-mobile-screen="list"] .file-panel {
    position: relative !important;
    inset: auto !important;
    z-index: auto;
    width: 100%;
    max-width: none;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    border: 0;
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
    overflow: hidden;
    animation: mobileListIn 180ms ease-out both;
  }

  .app-shell[data-mobile-screen="list"] .file-panel .panel-bar {
    min-height: calc(62px + env(safe-area-inset-top, 0px));
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .app-shell[data-mobile-screen="list"] .file-panel .panel-bar h2 {
    min-width: 48px;
    flex: 0 0 auto;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: 1.08rem;
    line-height: 1.25;
  }

  .app-shell[data-mobile-screen="list"] .file-panel .panel-actions,
  .app-shell[data-file-panel="collapsed"][data-mobile-screen="list"] .file-panel .panel-actions {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
  }

  .app-shell[data-mobile-screen="list"] .mobile-header-search {
    order: 0;
    min-width: 0;
    min-height: 40px;
    flex: 0 1 clamp(72px, 22vw, 92px);
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 9px;
    background: var(--surface-soft);
    color: var(--muted);
  }

  .app-shell[data-mobile-screen="list"] .mobile-header-search svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
  }

  .app-shell[data-mobile-screen="list"] .mobile-header-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    padding: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 16px;
  }

  .app-shell[data-mobile-screen="list"] .file-panel [data-action="upload-files"],
  .app-shell[data-mobile-screen="list"] .file-panel [data-action="download-selected-files"],
  .app-shell[data-mobile-screen="list"] .file-panel [data-action="toggle-file-panel"] {
    display: none !important;
  }

  .app-shell[data-mobile-screen="list"] .file-panel [data-action="sort-files"] {
    display: inline-flex;
    order: 3;
  }

  .app-shell[data-mobile-screen="list"] .mobile-library-action {
    display: inline-flex !important;
  }

  .app-shell[data-mobile-screen="list"] .file-panel [data-action="new-note"] {
    order: 1;
  }

  .app-shell[data-mobile-screen="list"] .file-panel [data-action="create-folder"] {
    order: 2;
  }

  .app-shell[data-mobile-screen="list"] .file-panel [data-action="mobile-settings"] {
    order: 4;
  }

  .app-shell[data-mobile-screen="list"] .file-panel .icon-button {
    flex: 0 0 40px;
    width: 40px;
    min-height: 40px;
    border-radius: 8px;
    touch-action: manipulation;
  }

  .app-shell[data-mobile-screen="list"] .file-panel .icon-button svg {
    width: 18px;
    height: 18px;
  }

  .app-shell[data-mobile-screen="list"] .file-tools {
    display: none !important;
  }

  .app-shell[data-mobile-screen="list"] .file-tools[hidden] {
    display: none !important;
  }

  .app-shell[data-mobile-screen="list"] .file-search {
    min-height: 42px;
    border-radius: 8px;
    padding: 0 12px;
    background: var(--surface-soft);
  }

  .app-shell[data-mobile-screen="list"] .file-search svg {
    width: 17px;
    height: 17px;
  }

  .app-shell[data-mobile-screen="list"] .file-search input {
    font-size: 16px;
  }

  .app-shell[data-mobile-screen="list"] .file-bottom-tools {
    display: none !important;
  }

  .app-shell[data-mobile-screen="list"] .file-list {
    grid-row: 3;
    min-height: 0;
    display: block;
    overflow: auto;
    padding: 8px 10px 14px;
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
  }

  .app-shell[data-mobile-screen="list"] .directory-panel {
    min-height: auto;
  }

  .app-shell[data-mobile-screen="list"] .directory-tree,
  .app-shell[data-mobile-screen="list"] .search-result-list {
    gap: 3px;
  }

  .app-shell[data-mobile-screen="list"] .tree-row {
    height: 50px;
    grid-template-columns: 32px minmax(0, 1fr) 42px;
    padding-left: calc(var(--tree-depth, 0) * 14px);
    border-radius: 8px;
  }

  .app-shell[data-mobile-screen="list"] .tree-toggle {
    width: 32px;
    height: 50px;
  }

  .app-shell[data-mobile-screen="list"] .tree-toggle svg {
    width: 16px;
    height: 16px;
  }

  .app-shell[data-mobile-screen="list"] .tree-label {
    height: 50px;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 9px;
    padding: 0 6px 0 1px;
  }

  .app-shell[data-mobile-screen="list"] .tree-label svg {
    width: 19px;
    height: 19px;
  }

  .app-shell[data-mobile-screen="list"] .tree-label span {
    font-size: 0.96rem;
  }

  .app-shell[data-mobile-screen="list"] .tree-menu-button {
    width: 42px;
    height: 50px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 8px;
  }

  .app-shell[data-mobile-screen="list"] .tree-menu-button svg {
    width: 20px;
    height: 20px;
  }

  .app-shell[data-mobile-screen="list"] .search-result-item {
    min-height: 56px;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: center;
    border-radius: 8px;
    padding: 9px 10px;
  }

  .app-shell[data-mobile-screen="list"] .search-result-title {
    font-size: 0.95rem;
  }

  .app-shell[data-mobile-screen="list"] .search-result-snippet,
  .app-shell[data-mobile-screen="list"] .file-search-summary {
    font-size: 0.78rem;
  }

  .app-shell[data-mobile-screen="list"] .login-form {
    gap: 14px;
    margin: 14px 12px;
    padding: 18px 16px;
    border-radius: 12px;
  }

  .app-shell[data-mobile-screen="list"] .login-heading strong {
    font-size: 1.06rem;
  }

  .app-shell[data-mobile-screen="list"] .login-form input,
  .app-shell[data-mobile-screen="list"] .login-form .primary-button {
    min-height: 44px;
    border-radius: 8px;
    font-size: 16px;
  }

  .password-input-wrap input,
  .modal-field .password-input-wrap input {
    padding-right: 48px;
  }

  .password-visibility-button {
    right: 5px;
    width: 38px;
    height: 36px;
    touch-action: manipulation;
  }

  .app-shell[data-mobile-screen="list"] .document-workspace {
    display: none !important;
  }

  .document-workspace,
  html[data-initial-view="split"] .document-workspace,
  .app-shell[data-view="split"] .document-workspace,
  .app-shell[data-mobile-screen="detail"] .document-workspace {
    grid-row: 1;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    background: var(--surface);
    overflow: hidden;
  }

  .app-shell[data-mobile-screen="detail"] .document-workspace {
    animation: mobileDetailIn 190ms ease-out both;
  }

  .app-shell[data-mobile-screen="detail"] .panel,
  .app-shell[data-mobile-screen="detail"] .editor-panel,
  .app-shell[data-mobile-screen="detail"] .preview-panel {
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
  }

  .app-shell[data-mobile-screen="detail"] .preview-panel {
    background: var(--bg);
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .app-shell[data-mobile-screen="detail"] .preview-panel {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel .panel-bar,
  .app-shell[data-mobile-screen="detail"] .preview-panel .panel-bar {
    min-height: 0;
    display: block;
    padding: 8px 10px 9px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel .panel-bar h2,
  .app-shell[data-mobile-screen="detail"] .preview-panel .panel-bar h2 {
    display: none;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel .panel-actions,
  .app-shell[data-mobile-screen="detail"] .preview-panel .panel-actions {
    width: 100%;
    min-width: 0;
    display: grid;
    align-items: center;
    justify-content: start;
    gap: 8px 6px;
    overflow-x: hidden;
    overflow-y: visible;
    padding: 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel .panel-actions {
    grid-template-columns: repeat(8, 40px);
    grid-template-areas:
      "mode mode mode ai import pdf view view"
      "font bold strike color clear line bullet number";
    align-content: flex-start;
  }

  .app-shell[data-mobile-screen="detail"][data-document-mode="json"] .editor-panel .panel-actions {
    grid-template-columns: 40px 40px 40px 40px 40px 84px;
    grid-template-areas:
      "mode mode mode import pdf view"
      "font line . . . .";
  }

  .app-shell[data-mobile-screen="detail"] .preview-panel .panel-actions {
    width: 100%;
    max-width: 100%;
    grid-template-columns: 90px 38px 38px 38px;
    grid-template-areas: "view copy download pdf";
    gap: 8px;
  }

  .app-shell[data-mobile-screen="detail"] .preview-panel .panel-bar {
    min-height: 50px;
    display: flex;
    align-items: center;
    padding: 6px 10px;
  }

  .app-shell[data-mobile-screen="detail"] .panel-actions::-webkit-scrollbar {
    display: none;
  }

  .app-shell[data-mobile-screen="detail"] .panel-action-spacer,
  .app-shell[data-mobile-screen="detail"] [data-view-mode="split"] {
    display: none !important;
  }

  .app-shell[data-mobile-screen="detail"] .preview-view-modes,
  .app-shell[data-mobile-screen="detail"][data-view="editor"] .editor-view-modes {
    display: inline-flex !important;
  }

  .app-shell[data-mobile-screen="detail"][data-document-mode="text"] .preview-view-modes,
  .app-shell[data-mobile-screen="detail"][data-document-mode="mindmap"] .preview-view-modes {
    display: none !important;
  }

  .app-shell[data-mobile-screen="detail"] .document-mode-toggle {
    grid-area: mode;
    width: 166px;
  }

  .app-shell[data-mobile-screen="detail"] .preview-view-modes {
    grid-area: view;
    width: 84px;
  }

  .app-shell[data-mobile-screen="detail"] .preview-panel .preview-view-modes {
    grid-area: view;
    width: 90px;
    flex: 0 0 90px;
  }

  .app-shell[data-mobile-screen="detail"] .toolbar-menu,
  .app-shell[data-mobile-screen="detail"] .panel-bar .icon-button {
    justify-self: start;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel [data-action="ai-optimize"] {
    grid-area: ai;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel [data-action="import"] {
    grid-area: import;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel [data-action="download-pdf"] {
    grid-area: pdf;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel [data-action="download-md"].editor-download-button {
    display: none;
  }

  .app-shell[data-mobile-screen="detail"] .preview-panel [data-action="copy-text"] {
    grid-area: copy;
  }

  .app-shell[data-mobile-screen="detail"] .preview-panel [data-action="download-md"] {
    grid-area: download;
  }

  .app-shell[data-mobile-screen="detail"] .preview-panel [data-action="download-pdf"] {
    grid-area: pdf;
  }

  .app-shell[data-mobile-screen="detail"] .pdf-download-button::after {
    right: 1px;
    bottom: 1px;
    min-width: 13px;
    height: 7px;
    font-size: 4px;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel [data-rich-menu="fontSize"] {
    grid-area: font;
    margin-left: 0;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel .bold-button {
    grid-area: bold;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel .strike-button {
    grid-area: strike;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel .color-button {
    grid-area: color;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel [data-action="clear-format"] {
    grid-area: clear;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel [data-rich-menu="lineHeight"] {
    grid-area: line;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel [data-action="toggle-bullet-list"] {
    grid-area: bullet;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel [data-action="toggle-numbered-list"] {
    grid-area: number;
  }

  .app-shell[data-mobile-screen="detail"] .editor-panel .panel-actions > [data-action="save-file"],
  .app-shell[data-mobile-screen="detail"] .editor-panel .panel-actions > [data-action="new-draft"],
  .app-shell[data-mobile-screen="detail"] .preview-panel .panel-actions > [data-action="new-draft"],
  .app-shell[data-mobile-screen="detail"] [data-action="upload-files"] {
    display: none;
  }

  .app-shell[data-mobile-screen="detail"] .panel-bar .segmented {
    width: auto;
    min-width: 0;
    height: 38px;
    min-height: 38px;
    flex: 0 0 auto;
    padding: 3px;
  }

  .app-shell[data-mobile-screen="detail"] .panel-bar .segment {
    min-width: 0;
    height: 100%;
    flex: 1 1 0;
    padding: 0 6px;
    display: inline-grid;
    place-items: center;
    font-size: 0.78rem;
  }

  .app-shell[data-mobile-screen="detail"] .document-mode-toggle .segment {
    min-width: 0;
    width: auto;
    padding: 0;
  }

  .app-shell[data-mobile-screen="detail"] .document-mode-toggle .segment span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .app-shell[data-mobile-screen="detail"] .document-mode-toggle .segment svg {
    display: block;
    width: 17px;
    height: 17px;
  }

  .app-shell[data-mobile-screen="detail"] .document-mode-toggle .segment i {
    display: block;
  }

  .app-shell[data-mobile-screen="detail"] .toolbar-menu {
    min-width: 0;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }

  .app-shell[data-mobile-screen="detail"] .panel-bar .icon-button,
  .app-shell[data-mobile-screen="detail"] .toolbar-menu-trigger {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 8px;
    touch-action: manipulation;
  }

  .app-shell[data-mobile-screen="detail"] .panel-bar .icon-button svg {
    width: 18px;
    height: 18px;
  }

  .app-shell[data-mobile-screen="detail"] .preview-panel .panel-bar .icon-button {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    height: 38px;
    flex: 0 0 38px;
  }

  .app-shell[data-mobile-screen="detail"] .preview-panel .panel-bar .segmented {
    height: 36px;
    min-height: 36px;
  }

  .app-shell[data-mobile-screen="detail"] .text-format-button span,
  .app-shell[data-mobile-screen="detail"] .color-button span {
    min-width: 18px;
    height: 18px;
    font-size: 1.02rem;
  }

  .app-shell[data-mobile-screen="detail"] .color-button {
    position: relative;
    color: var(--danger);
  }

  .app-shell[data-mobile-screen="detail"] .color-button::after {
    content: none;
  }

  .toolbar-menu-panel {
    position: fixed;
    top: calc(106px + env(safe-area-inset-top, 0px));
    right: 10px;
    z-index: 180;
    max-height: min(320px, 58dvh);
    overflow: auto;
  }

  .ai-draft-bar {
    gap: 8px;
    padding: 8px 10px;
  }

  .ai-draft-source {
    font-size: 0.8rem;
  }

  #markdownInput,
  .rich-editor,
  .mindmap-editor {
    padding: 16px 14px 20px;
    font-size: 16px;
    line-height: 1.7;
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
  }

  .markdown-preview {
    width: min(calc(100% - 24px), 680px);
    justify-self: center;
    padding: 18px 18px 26px;
    font-size: 16px;
    line-height: 1.68;
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
  }

  .app-shell[data-mobile-screen="detail"] .preview-panel .markdown-preview {
    height: 100%;
    min-height: 0;
  }

  .plain-text-preview-host,
  .json-preview-host,
  .mindmap-preview-host {
    padding: 16px 14px 22px;
  }

  .mindmap-canvas {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 34px;
    overflow: auto;
  }

  .mindmap-canvas::before {
    display: none;
  }

  .mindmap-center {
    min-height: 0;
    order: -1;
    padding: 7px 11px;
    font-size: 1.25rem;
  }

  .mindmap-side-left .mindmap-node {
    text-align: left;
  }

  .mindmap-branch-list::before,
  .mindmap-branch-list .mindmap-branch-list::after {
    left: 12px;
    right: auto;
  }

  .mindmap-side-left .mindmap-branch-list,
  .mindmap-side-right .mindmap-branch-list {
    padding-left: 34px;
    padding-right: 0;
  }

  .mindmap-side-left .mindmap-branch::before,
  .mindmap-side-right .mindmap-branch::before {
    left: 0;
    right: auto;
    width: 34px;
  }

  .mindmap-empty-branch {
    display: none;
  }

  .mindmap-editor jmnode {
    max-width: min(270px, 68vw);
    padding: 6px 0.5em 7px;
  }

  .mindmap-editor jmnode.has-note {
    padding-right: calc(0.5em + 18px);
  }

  .mindmap-editor jmnode.root,
  .mindmap-editor jmnode.mindmap-root-node {
    max-width: min(300px, 74vw);
    min-width: var(--mindmap-root-min-width);
    padding: 7px 0.5em;
  }

  .mindmap-editor jmnode.root.has-note,
  .mindmap-editor jmnode.mindmap-root-node.has-note {
    padding-right: calc(0.5em + 18px);
  }

  .app-shell[data-mobile-screen="detail"][data-document-mode="json"] .json-preview-host {
    padding: 14px 12px 18px;
  }

  .app-shell[data-mobile-screen="detail"][data-document-mode="json"] .json-preview {
    font-size: 15px;
    line-height: 1.7;
  }

  .markdown-preview h1 {
    font-size: 1.55rem;
  }

  .markdown-preview h2 {
    font-size: 1.28rem;
  }

  .markdown-preview pre {
    border-radius: 8px;
    padding: 12px;
  }

  .statusbar {
    min-height: calc(42px + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.72rem;
  }

  .statusbar-meta {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .statusbar-meta #documentStats {
    flex: 1 1 auto;
  }

  .statusbar-meta #saveStatus {
    flex: 0 1 auto;
  }

  .filing-link {
    flex: 0 1 auto;
    max-width: 42vw;
  }

  .app-shell[data-mobile-screen="list"] .statusbar {
    display: flex;
    justify-content: center;
  }

  .app-shell[data-mobile-screen="list"] .statusbar-meta {
    display: none;
  }

  .statusbar span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .context-menu {
    z-index: 220;
    max-width: calc(100vw - 18px);
  }

  .modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0 8px calc(8px + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
  }

  .modal[open] {
    display: grid;
    align-items: end;
    justify-items: center;
  }

  .modal::backdrop {
    background: rgba(15, 23, 42, 0.56);
    backdrop-filter: blur(4px);
  }

  .modal-card {
    position: relative;
    width: min(100%, 560px);
    max-height: calc(100dvh - 14px - env(safe-area-inset-bottom, 0px));
    display: grid;
    gap: 0;
    overflow: hidden;
    padding: 0;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: var(--surface);
    box-shadow: 0 -18px 48px rgba(15, 23, 42, 0.32);
    animation: mobileSheetIn 180ms ease-out both;
  }

  .modal-card::before {
    content: "";
    justify-self: center;
    width: 36px;
    height: 4px;
    margin-top: 8px;
    border-radius: 999px;
    background: var(--border);
  }

  .modal-header {
    min-height: 54px;
    padding: 10px 14px 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .modal-header h2 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.06rem;
    line-height: 1.25;
  }

  .modal-header .icon-button {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 8px;
    touch-action: manipulation;
  }

  .modal-description {
    margin: 14px 16px 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.55;
  }

  .modal-card > .modal-field {
    margin: 14px 16px 0;
  }

  .modal-field {
    gap: 8px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
  }

  .modal-field input,
  .modal-field select {
    min-height: 46px;
    border-radius: 8px;
    padding: 0 12px;
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
  }

  .modal-field input:focus,
  .modal-field select:focus,
  .ai-textarea:focus {
    outline: 3px solid var(--accent-soft);
    outline-offset: 0;
  }

  .modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: var(--surface);
  }

  .modal-actions .text-button,
  .modal-actions .primary-button {
    min-width: 0;
    min-height: 44px;
    flex: 1 1 0;
    border-radius: 8px;
    padding: 0 14px;
    font-size: 0.94rem;
    touch-action: manipulation;
  }

  .modal-actions .text-button {
    border-color: var(--border);
    background: var(--surface-soft);
    color: var(--text);
  }

  .modal-actions .primary-button,
  .ai-actions [data-ai-save],
  .user-actions [data-user-create] {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
    font-weight: 800;
  }

  .danger-button,
  .danger-button:hover {
    border-color: var(--danger);
    background: var(--danger);
    color: #ffffff;
  }

  .ai-settings-card,
  .user-management-card {
    width: min(100%, 620px);
    max-height: calc(100dvh - 14px - env(safe-area-inset-bottom, 0px));
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .ai-layout,
  .user-management-layout {
    min-height: 0;
    overflow: auto;
    gap: 16px;
    padding: 14px 16px 16px;
    -webkit-overflow-scrolling: touch;
  }

  .ai-section,
  .user-section {
    gap: 12px;
    padding-top: 0;
    border-top: 0;
  }

  .ai-section + .ai-section,
  .user-section + .user-section {
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }

  .ai-section-title,
  .user-section-title {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
  }

  .ai-grid,
  .user-create-grid,
  .user-password-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .ai-textarea {
    min-height: 176px;
    border-radius: 8px;
    padding: 12px;
    background: var(--surface);
    font-size: 16px;
  }

  .ai-prompt-text {
    min-height: 210px;
  }

  .ai-status {
    min-width: 0;
    flex: 1 0 100%;
    font-size: 0.82rem;
  }

  .user-section-actions {
    justify-content: stretch;
  }

  .user-section-actions .text-button {
    width: 100%;
    min-height: 44px;
    border-color: var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 800;
  }

  .user-list {
    gap: 8px;
  }

  .user-row {
    min-height: 52px;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 11px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--surface-soft);
  }

  .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }

  .upload-card {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border);
  }

  .upload-card .modal-header h2,
  .upload-card .icon-button,
  .upload-card .text-button {
    color: var(--text);
  }

  .upload-card .icon-button {
    border-color: var(--border);
    background: var(--surface);
  }

  .upload-card .ai-status,
  .upload-drop-text span {
    color: var(--muted);
  }

  .upload-drop-zone {
    min-height: 176px;
    margin: 16px;
    padding: 24px 18px;
    border-color: var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
  }

  .upload-drop-zone svg {
    width: 34px;
    height: 34px;
    color: var(--accent-strong);
  }

  .upload-drop-zone.is-dragging,
  .upload-drop-zone:focus-visible {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }

  .mobile-settings-card {
    width: min(100%, 430px);
    max-height: min(78dvh, calc(100dvh - 18px - env(safe-area-inset-bottom, 0px)));
  }

  .mobile-settings-list {
    min-height: 0;
    display: grid;
    gap: 0;
    overflow: auto;
    padding: 8px 10px 14px;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-setting-item {
    width: 100%;
    min-height: 62px;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 9px 6px;
    background: transparent;
    color: var(--text);
    text-align: left;
    touch-action: manipulation;
  }

  .mobile-setting-item:last-child {
    border-bottom: 0;
  }

  .mobile-setting-item:active {
    background: var(--surface-soft);
    transform: none;
  }

  .mobile-setting-item:hover,
  .mobile-setting-item:focus-visible {
    background: var(--surface-soft);
    outline: 0;
  }

  .mobile-setting-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--accent-strong);
  }

  .mobile-setting-item[data-variant="danger"] .mobile-setting-icon,
  .mobile-setting-item[data-variant="danger"] .mobile-setting-label {
    color: var(--danger);
  }

  .mobile-setting-icon svg {
    width: 19px;
    height: 19px;
  }

  .mobile-setting-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
  }

  .mobile-setting-label,
  .mobile-setting-meta,
  .mobile-setting-state {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-setting-label {
    color: var(--text);
    font-size: 0.96rem;
    font-weight: 800;
  }

  .mobile-setting-meta {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
  }

  .mobile-setting-state {
    color: var(--accent-strong);
    font-size: 0.84rem;
    font-weight: 800;
  }

  .mobile-setting-chevron {
    width: 18px;
    height: 18px;
    color: var(--muted);
  }

  @media (hover: none) {
    .segment:hover,
    .tool-button:hover,
    .text-button:hover,
    .icon-button:hover,
    .mobile-setting-item:hover {
      border-color: var(--border);
      background: var(--surface);
    }

    .segment.is-active:hover,
    .icon-button.is-active:hover {
      border-color: var(--accent);
      background: var(--accent-soft);
    }

    .mobile-setting-item:hover {
      background: transparent;
    }

    .color-button:hover {
      border-color: var(--border);
      background: var(--surface);
      color: var(--danger);
    }
  }

  @keyframes mobileDetailIn {
    from {
      opacity: 0.78;
      transform: translateX(22px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  @keyframes mobileListIn {
    from {
      opacity: 0.82;
      transform: translateX(-18px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  @keyframes mobileSheetIn {
    from {
      opacity: 0.86;
      transform: translateY(18px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @media (max-height: 560px) {
    .modal {
      padding: 4px;
    }

    .modal-card,
    .ai-settings-card,
    .user-management-card {
      max-height: calc(100dvh - 8px);
    }

    .mobile-settings-card {
      max-height: calc(100dvh - 8px);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .app-shell[data-mobile-screen="list"] .file-panel,
    .app-shell[data-mobile-screen="detail"] .document-workspace,
    .modal-card {
      animation: none;
    }
  }
}
