/* ============================================================
   Ez-Pad – Design System
   「道具としての美しさ」 Notion × Linear × Vercel
   ============================================================ */

/* ── Google Fonts ──────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Custom Properties ──────────────────────────────────── */
:root {
  --bg-base      : #0a0a0f;
  --bg-surface   : #13131a;
  --bg-elevated  : #1c1c28;
  --border       : #2a2a3d;
  --accent       : #6366f1;
  --accent-glow  : rgba(99, 102, 241, 0.15);
  --text-primary : #f0f0ff;
  --text-muted   : #6b6b8d;
  --success      : #22d3a5;
  --danger       : #f87171;

  --font-display : 'DM Sans', sans-serif;
  --font-mono    : 'JetBrains Mono', monospace;

  --radius       : 12px;
  --radius-sm    : 8px;
  --sidebar-w    : 64px;
  --transition   : 200ms ease-out;
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-display);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Layout Shell ────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 4px;
  z-index: 10;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.sidebar-divider {
  width: 32px;
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.nav-item {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  border: none;
  background: transparent;
  transition: background var(--transition), color var(--transition), transform var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  transform: scale(1.05);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), inset 0 0 12px var(--accent-glow);
}

/* Tooltip */
.nav-item::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  border: 1px solid var(--border);
}

.nav-item:hover::after {
  opacity: 1;
}

/* ── Main Content ────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Views ───────────────────────────────────────────────────── */
.view {
  display: none;
  flex: 1;
  overflow: hidden;
  animation: fadeIn var(--transition) forwards;
}

.view.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Memo View – 2-pane layout ───────────────────────────────── */
#memo-view {
  flex-direction: row;
}

/* Memo sidebar */
.memo-list-pane {
  width: 280px;
  min-width: 280px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pane-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Button variants */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  white-space: nowrap;
}

.btn:hover { transform: scale(1.02); }
.btn:active { transform: scale(0.98); }

.btn-solid {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.btn-solid:hover {
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.55);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
  background: var(--bg-elevated);
}

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

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.1);
}

.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  transition: background var(--transition), color var(--transition), transform var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  transform: scale(1.05);
}

/* Memo list */
.memo-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.memo-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background var(--transition), border-color var(--transition);
  animation: slideIn var(--transition) forwards;
  margin-bottom: 2px;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.memo-item:hover {
  background: var(--bg-elevated);
}

.memo-item.selected {
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.memo-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.memo-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.memo-item-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.empty-state-desc {
  font-size: 13px;
  line-height: 1.6;
}

/* ── Memo Editor Pane ────────────────────────────────────────── */
.memo-editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.editor-toolbar-left { flex: 1; display: flex; align-items: center; gap: 8px; }
.editor-toolbar-right { display: flex; align-items: center; gap: 6px; }

.mode-toggle {
  display: flex;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.mode-btn {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.mode-btn.active {
  background: var(--accent);
  color: #fff;
}

.save-indicator {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.save-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

.save-dot.saving {
  background: var(--accent);
  animation: spin 1s linear infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Memo title input */
.memo-title-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 24px 24px 8px;
  line-height: 1.3;
}

.memo-title-input::placeholder { color: var(--text-muted); }

/* Content area */
.editor-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.memo-textarea {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
  padding: 8px 24px 48px;
  line-height: 1.7;
}

.memo-textarea::placeholder { color: var(--text-muted); }

/* Markdown preview */
.markdown-preview {
  position: absolute;
  inset: 0;
  padding: 8px 24px 48px;
  overflow-y: auto;
  line-height: 1.8;
  display: none;
}

.markdown-preview.visible { display: block; }

.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 {
  color: var(--text-primary);
  margin: 1.5em 0 0.5em;
  font-weight: 600;
}

.markdown-preview h1 { font-size: 22px; }
.markdown-preview h2 { font-size: 18px; }
.markdown-preview h3 { font-size: 15px; }

.markdown-preview p { margin-bottom: 1em; }

.markdown-preview code {
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #a5b4fc;
}

.markdown-preview pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
  margin: 1em 0;
}

.markdown-preview pre code {
  background: transparent;
  padding: 0;
}

.markdown-preview blockquote {
  border-left: 3px solid var(--accent);
  margin: 1em 0;
  padding-left: 16px;
  color: var(--text-muted);
}

.markdown-preview a { color: var(--accent); }

.markdown-preview ul, .markdown-preview ol {
  margin: 0.5em 0 1em 1.5em;
}

.markdown-preview hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* Char counter */
.char-counter {
  position: absolute;
  bottom: 16px;
  right: 24px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Editor no-selection state */
.editor-no-selection {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  color: var(--text-muted);
}

/* ── File View ───────────────────────────────────────────────── */
#file-view {
  flex-direction: column;
  background: var(--bg-base);
  overflow-y: auto;
}

.file-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.file-header-title {
  font-size: 18px;
  font-weight: 600;
}

.file-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Drop Zone ───────────────────────────────────────────────── */
.drop-zone {
  margin: 24px 32px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: center;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-glow);
}

.drop-zone-icon { font-size: 40px; }
.drop-zone-title { font-size: 15px; font-weight: 500; }
.drop-zone-sub { font-size: 13px; color: var(--text-muted); }

.drop-zone input[type="file"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Upload progress */
.upload-progress-list {
  margin: 0 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  animation: slideIn var(--transition) forwards;
}

.upload-item-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.upload-item-meta { font-size: 11px; color: var(--text-muted); }

.progress-bar-track {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  border-radius: 2px;
  transition: width 200ms ease;
}

/* ── File list / grid ────────────────────────────────────────── */
.file-list-section {
  padding: 0 32px 32px;
}

.file-list-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.file-list-controls .label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex: 1;
}

.view-toggle {
  display: flex;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.view-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.view-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Grid layout */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.file-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  animation: slideIn var(--transition) forwards;
  position: relative;
}

.file-card:hover {
  background: var(--bg-elevated);
  border-color: var(--text-muted);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.file-card-icon { font-size: 32px; margin-bottom: 8px; }

.file-card-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.file-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.file-card-actions {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  gap: 4px;
}

.file-card:hover .file-card-actions { display: flex; }

/* List layout */
.file-list-view {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  animation: slideIn var(--transition) forwards;
}

.file-row:hover {
  background: var(--bg-elevated);
  border-color: var(--text-muted);
}

.file-row-icon { font-size: 20px; }

.file-row-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row-size, .file-row-date {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.file-row-actions { display: flex; gap: 4px; }

/* Skeleton screen */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
}

/* ── Inputs ──────────────────────────────────────────────────── */
input[type="text"],
input[type="password"],
textarea,
select {
  font-family: var(--font-display);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select option {
  background: var(--bg-elevated);
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn var(--transition) forwards;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  min-width: 360px;
  max-width: 480px;
  width: 90vw;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  animation: modalIn var(--transition) forwards;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-field {
  margin-bottom: 16px;
}

.modal-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.modal-field input,
.modal-field select {
  width: 100%;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

/* QR modal */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#qr-canvas {
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 12px;
}

.copy-url-row {
  display: flex;
  width: 100%;
  gap: 8px;
}

.copy-url-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ── Toast Notifications ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  min-width: 240px;
  max-width: 360px;
  font-size: 13px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toastIn 200ms ease-out forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.out {
  animation: toastOut 200ms ease-in forwards;
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

.toast-icon { font-size: 16px; }
.toast-msg  { flex: 1; line-height: 1.4; }

.toast.success { border-color: rgba(34, 211, 165, 0.4); }
.toast.success .toast-icon::before { content: '✓'; color: var(--success); }

.toast.error   { border-color: rgba(248, 113, 113, 0.4); }
.toast.error   .toast-icon::before { content: '✕'; color: var(--danger); }

.toast.info    { border-color: rgba(99, 102, 241, 0.4); }
.toast.info    .toast-icon::before { content: 'ℹ'; color: var(--accent); }

/* Undo action in toast */
.toast-undo {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  margin-left: 4px;
}

/* ── Context Menu ────────────────────────────────────────────── */
.context-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  min-width: 160px;
  z-index: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: fadeIn 150ms ease-out forwards;
}

.context-menu.hidden { display: none; }

.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition);
}

.ctx-item:hover { background: var(--bg-surface); }

.ctx-item.danger { color: var(--danger); }

.ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Image thumbnail ─────────────────────────────────────────── */
.file-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

/* ── Expiry badge ────────────────────────────────────────────── */
.expiry-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.expiry-badge.ok {
  background: rgba(34, 211, 165, 0.1);
  color: var(--success);
}

/* ── Mobile (≤768px) ─────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Dynamic viewport height fixes iOS address-bar jump */
  html, body {
    height: 100dvh;
  }

  #app {
    flex-direction: column;
    height: 100dvh;
    height: -webkit-fill-available;
  }

  /* ── Bottom navigation bar ─────────────────────────────────── */
  .sidebar {
    width: 100%;
    height: 56px;
    min-width: unset;
    flex-direction: row;
    justify-content: space-around;
    order: 2;
    flex-shrink: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0 0 env(safe-area-inset-bottom, 0px);
    gap: 0;
  }

  .sidebar-logo,
  .sidebar-divider { display: none; }

  .nav-item {
    flex: 1;
    height: 100%;
    width: auto;
    border-radius: 0;
    font-size: 22px;
  }

  /* No tooltips on touch */
  .nav-item::after { display: none; }

  /* ── Main area ─────────────────────────────────────────────── */
  .main {
    flex: 1;
    overflow: hidden;
    order: 1;
    min-height: 0;
  }

  /* ── Memo view: single-pane slide navigation ───────────────── */
  #memo-view {
    position: relative;
    overflow: hidden;
  }

  .memo-list-pane {
    position: absolute;
    inset: 0;
    width: 100%;
    min-width: unset;
    border-right: none;
    z-index: 2;
    transform: translateX(0);
    transition: transform 250ms ease-out;
  }

  .memo-list-pane.mobile-hidden {
    transform: translateX(-100%);
  }

  .memo-editor-pane {
    position: absolute;
    inset: 0;
    transform: translateX(100%);
    transition: transform 250ms ease-out;
  }

  .memo-editor-pane.mobile-visible {
    transform: translateX(0);
  }

  /* ── Editor toolbar: scrollable, no overflow ───────────────── */
  .editor-toolbar {
    padding: 8px 12px;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .editor-toolbar::-webkit-scrollbar { display: none; }

  /* ── Mobile back button ────────────────────────────────────── */
  #mobile-back-btn { display: none; }

  /* ── Title & textarea ──────────────────────────────────────── */
  .memo-title-input {
    font-size: 20px;
    padding: 16px 16px 8px;
  }

  .memo-textarea {
    padding: 8px 16px 48px;
  }

  .markdown-preview {
    padding: 8px 16px 48px;
  }

  /* ── File view ─────────────────────────────────────────────── */
  .file-header {
    padding: 16px;
  }

  .file-header-title { font-size: 16px; }

  .drop-zone {
    margin: 12px;
    padding: 28px 16px;
  }

  .drop-zone-sub { font-size: 12px; }

  .upload-progress-list { margin: 0 12px 8px; }

  .file-list-section { padding: 0 12px 16px; }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
  }

  /* File card: always show actions (no hover on touch) */
  .file-card-actions { display: flex; }

  /* File row: hide size/date columns */
  .file-row {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding: 8px 12px;
  }

  .file-row-size,
  .file-row-date { display: none; }

  /* ── Toast: above bottom nav ───────────────────────────────── */
  #toast-container {
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    left: 12px;
  }

  .toast {
    min-width: unset;
    width: 100%;
    max-width: 100%;
  }

  /* ── Modal ─────────────────────────────────────────────────── */
  .modal {
    width: calc(100vw - 24px);
    min-width: unset;
    padding: 20px;
  }

  /* ── FAB: floating new-memo button ─────────────────────────── */
  .mobile-fab {
    position: fixed;
    right: 20px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 30px;
    line-height: 1;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: transform var(--transition), box-shadow var(--transition);
  }

  .mobile-fab:active {
    transform: scale(0.93);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
  }
}

/* ── Staggered card animations ───────────────────────────────── */
.file-card:nth-child(1)  { animation-delay: 0ms; }
.file-card:nth-child(2)  { animation-delay: 50ms; }
.file-card:nth-child(3)  { animation-delay: 100ms; }
.file-card:nth-child(4)  { animation-delay: 150ms; }
.file-card:nth-child(5)  { animation-delay: 200ms; }
.file-card:nth-child(6)  { animation-delay: 250ms; }
.file-card:nth-child(n+7){ animation-delay: 300ms; }

.memo-item:nth-child(1)  { animation-delay: 0ms; }
.memo-item:nth-child(2)  { animation-delay: 50ms; }
.memo-item:nth-child(3)  { animation-delay: 100ms; }
.memo-item:nth-child(n+4){ animation-delay: 150ms; }

/* ── PIN lock overlay ────────────────────────────────────────── */
.pin-lock-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
}

.pin-lock-screen h2 { font-size: 18px; }
.pin-lock-screen p  { color: var(--text-muted); font-size: 14px; }
.pin-input-row { display: flex; gap: 8px; }
