:root,
:root[data-theme="light"] {
  --bg: #f4efe4;
  --bg-2: #ece6d8;
  --card: #fffdf8;
  --card-2: #f8f4ea;
  --line: #e4dccb;
  --text: #1f2721;
  --muted: #6f7468;
  --accent: #3c6a49;
  --accent-ink: #ffffff;
  --accent-soft: #e3ecdf;
  --danger: #b3412f;
  --warn: #c98b2b;
  --leaf: #5f8a62;
  --leaf-op: .22;
  --shadow: 0 1px 2px rgba(40, 35, 20, .05), 0 8px 24px rgba(40, 35, 20, .06);
}
:root[data-theme="dark"] {
  --bg: #121512;
  --bg-2: #191d19;
  --card: #1c211d;
  --card-2: #222823;
  --line: #2c332d;
  --text: #ebeee6;
  --muted: #98a094;
  --accent: #8cc296;
  --accent-ink: #0f1a12;
  --accent-soft: #233328;
  --danger: #e2785f;
  --warn: #e0b060;
  --leaf: #6f9e76;
  --leaf-op: .14;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
}
:root[data-theme="sepia"] {
  --bg: #efe2c6;
  --bg-2: #e6d6b5;
  --card: #f8eedb;
  --card-2: #f1e4c9;
  --line: #dcc9a3;
  --text: #3d2e1c;
  --muted: #7d6a50;
  --accent: #8a5a2b;
  --accent-ink: #fff8ec;
  --accent-soft: #ead8b6;
  --danger: #a43a24;
  --warn: #b07a1f;
  --leaf: #7a6a3a;
  --leaf-op: .2;
  --shadow: 0 1px 2px rgba(80, 55, 20, .06), 0 8px 24px rgba(80, 55, 20, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, h3, .serif { font-family: Fraunces, Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: -0.01em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Leaves decoration */
.leaves { position: fixed; pointer-events: none; z-index: 0; width: 340px; height: 340px; opacity: var(--leaf-op);
  background-color: var(--leaf);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.6'%3E%3Cpath d='M195 5C150 30 110 60 80 110S30 180 5 195'/%3E%3Cpath d='M150 32c-6 14-4 28 6 38M120 55c-8 14-7 30 3 40M95 85c-10 13-10 30-1 41M72 120c-10 11-12 26-5 38'/%3E%3C/g%3E%3Cg%3E%3Cpath d='M150 32c18-6 32-2 40 10-16 8-30 6-40-10z'/%3E%3Cpath d='M138 40c-4-18 2-32 16-38 5 16 0 30-16 38z'/%3E%3Cpath d='M120 55c18-4 32 2 38 15-17 5-30 0-38-15z'/%3E%3Cpath d='M110 62c-6-17-1-32 12-39 6 15 2 30-12 39z'/%3E%3Cpath d='M95 85c18-2 31 6 35 19-17 3-29-4-35-19z'/%3E%3Cpath d='M86 92c-8-16-5-31 7-40 8 14 6 29-7 40z'/%3E%3Cpath d='M72 120c17 0 29 9 31 22-17 1-28-7-31-22z'/%3E%3Cpath d='M64 126c-9-15-8-30 3-40 9 13 8 28-3 40z'/%3E%3Cpath d='M48 152c16 1 27 10 28 23-16 0-26-9-28-23z'/%3E%3Cpath d='M40 156c-10-13-10-28 0-38 10 12 10 26 0 38z'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.6'%3E%3Cpath d='M195 5C150 30 110 60 80 110S30 180 5 195'/%3E%3Cpath d='M150 32c-6 14-4 28 6 38M120 55c-8 14-7 30 3 40M95 85c-10 13-10 30-1 41M72 120c-10 11-12 26-5 38'/%3E%3C/g%3E%3Cg%3E%3Cpath d='M150 32c18-6 32-2 40 10-16 8-30 6-40-10z'/%3E%3Cpath d='M138 40c-4-18 2-32 16-38 5 16 0 30-16 38z'/%3E%3Cpath d='M120 55c18-4 32 2 38 15-17 5-30 0-38-15z'/%3E%3Cpath d='M110 62c-6-17-1-32 12-39 6 15 2 30-12 39z'/%3E%3Cpath d='M95 85c18-2 31 6 35 19-17 3-29-4-35-19z'/%3E%3Cpath d='M86 92c-8-16-5-31 7-40 8 14 6 29-7 40z'/%3E%3Cpath d='M72 120c17 0 29 9 31 22-17 1-28-7-31-22z'/%3E%3Cpath d='M64 126c-9-15-8-30 3-40 9 13 8 28-3 40z'/%3E%3Cpath d='M48 152c16 1 27 10 28 23-16 0-26-9-28-23z'/%3E%3Cpath d='M40 156c-10-13-10-28 0-38 10 12 10 26 0 38z'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat;
}
.leaves-tr { top: -40px; right: -40px; }
.leaves-tl { top: -40px; left: -40px; transform: scaleX(-1); }
.leaves-br { bottom: -40px; right: -40px; transform: rotate(180deg) scaleX(-1); }

/* Layout */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 28px 18px; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, var(--card)); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 0 8px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); font-family: Fraunces, serif; font-size: 20px; font-weight: 600; box-shadow: var(--shadow); }
.brand-mark.big { width: 64px; height: 64px; font-size: 38px; border-radius: 18px; margin-bottom: 8px; }
.brand-name { font-family: Fraunces, serif; font-size: 22px; font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--card-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg, .tabbar svg { width: 20px; height: 20px; flex: none; }
.logout { margin-top: auto; padding: 10px 12px; color: var(--muted); text-decoration: none; font-size: 14px; }
.logout:hover { color: var(--text); }

.main { padding: 40px clamp(16px, 4vw, 56px) 120px; max-width: 1100px; width: 100%; outline: none; min-width: 0; }

.tabbar { display: none; }

/* Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: clamp(34px, 5vw, 46px); line-height: 1.05; margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--card-2); color: var(--text); }
.crumbs .sep { opacity: .5; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 500; font-size: 14px; text-decoration: none; transition: background .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--card-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; justify-content: center; padding: 12px; }
.btn svg { width: 17px; height: 17px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--card-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* Search */
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search input { width: 100%; padding: 9px 14px 9px 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); outline: none; }
.search input:focus { border-color: var(--accent); }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }

/* Cards & lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tile { padding: 18px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; cursor: pointer; transition: transform .12s, border-color .12s; position: relative; min-height: 140px; }
.tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.tile h3 { margin: 0; font-size: 21px; line-height: 1.2; padding-right: 30px; }
.tile .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; gap: 8px; }
.tile .menu-btn { position: absolute; top: 10px; right: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.chip.neutral { background: var(--card-2); color: var(--muted); border: 1px solid var(--line); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip.btnlike { cursor: pointer; border: 1px solid transparent; }
.chip.btnlike.off { background: transparent; color: var(--muted); border-color: var(--line); }

.countdown { display: flex; align-items: baseline; gap: 6px; }
.countdown .num { font-family: Fraunces, serif; font-size: 40px; line-height: 1; }
.countdown .unit { color: var(--muted); font-size: 14px; }

.section-title { font-family: Fraunces, serif; font-size: 22px; margin: 32px 0 12px; }

.list { overflow: hidden; }
.row { display: grid; grid-template-columns: 40px 1fr auto auto 36px; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--card-2); }
.row .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--card-2); border: 1px solid var(--line); }
.row .ico svg { width: 18px; height: 18px; }
.row .ico.folder { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.row .ico.note { color: #6b5fb0; }
.row .ico.pdf { color: #b6473a; }
.row .ico.audio { color: #2f7d93; }
.row .ico.image { color: #a2722b; }
.row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row .name small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.row .size, .row .date { color: var(--muted); font-size: 13px; white-space: nowrap; }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty h3 { font-size: 24px; color: var(--text); margin: 0 0 6px; }
.empty .btn { margin-top: 16px; }

/* Dropdown menu */
.menu { position: fixed; z-index: 60; min-width: 190px; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: transparent; border-radius: 9px; cursor: pointer; text-align: left; font-size: 14px; }
.menu button:hover { background: var(--card-2); }
.menu button.danger { color: var(--danger); }
.menu svg { width: 17px; height: 17px; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }

/* Modal */
.modal-root:empty { display: none; }
.modal-root { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(20, 18, 12, .35); backdrop-filter: blur(2px); }
.modal { width: min(460px, 100%); max-height: 90vh; overflow: auto; padding: 24px; }
.modal h2 { margin: 0 0 16px; font-size: 26px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 12px; }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); color: var(--text); font-size: 15px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.folder-pick { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.folder-pick button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: transparent; cursor: pointer; border-bottom: 1px solid var(--line); }
.folder-pick button:last-child { border-bottom: 0; }
.folder-pick button:hover { background: var(--card-2); }
.folder-pick button:disabled { opacity: .4; cursor: not-allowed; }

/* Note editor */
.editor-wrap { padding: 0; overflow: hidden; }
.editor-title { width: 100%; border: 0; background: transparent; outline: none; font-family: Fraunces, serif; font-size: clamp(28px, 4vw, 38px); padding: 24px 28px 8px; color: var(--text); }
.toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--card-2); position: sticky; top: 0; z-index: 2; }
.toolbar button { min-width: 34px; height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-weight: 600; color: var(--muted); }
.toolbar button:hover { background: var(--card); color: var(--text); }
.toolbar .sep { width: 1px; background: var(--line); margin: 4px 6px; }
.editor { min-height: 55vh; padding: 20px 28px 40px; outline: none; font-size: 16px; line-height: 1.7; }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.editor h1 { font-size: 30px; margin: 18px 0 8px; }
.editor h2 { font-size: 24px; margin: 16px 0 6px; }
.editor h3 { font-size: 19px; margin: 14px 0 4px; }
.editor blockquote { margin: 10px 0; padding: 8px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.editor mark { background: color-mix(in srgb, var(--warn) 35%, transparent); color: inherit; padding: 0 2px; border-radius: 3px; }
.editor img { max-width: 100%; border-radius: 10px; }
.save-state { font-size: 13px; color: var(--muted); }

/* Viewer */
.viewer { padding: 0; overflow: hidden; }
.viewer iframe { width: 100%; height: 78vh; border: 0; display: block; background: #fff; }
.viewer img { display: block; max-width: 100%; margin: 0 auto; }
.viewer .pad { padding: 28px; }
.audio-card { padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.audio-card audio { width: 100%; }
.speed { display: flex; gap: 6px; flex-wrap: wrap; }

/* Settings */
.settings { display: grid; gap: 16px; max-width: 720px; }
.settings .card { padding: 22px; }
.settings h2 { margin: 0 0 4px; font-size: 22px; }
.settings p { margin: 0 0 14px; }
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-opt { border: 2px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; background: transparent; text-align: left; }
.theme-opt.active { border-color: var(--accent); }
.theme-opt .sw { height: 54px; border-radius: 9px; margin-bottom: 8px; display: flex; align-items: flex-end; padding: 8px; font-family: Fraunces, serif; font-size: 18px; }
.sw.light { background: #f4efe4; color: #1f2721; }
.sw.dark { background: #121512; color: #ebeee6; }
.sw.sepia { background: #efe2c6; color: #3d2e1c; }
.stat-row { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-row div { display: flex; flex-direction: column; }
.stat-row b { font-family: Fraunces, serif; font-size: 26px; font-weight: 500; }
.stat-row span { color: var(--muted); font-size: 13px; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; }
.auth-card { position: relative; z-index: 1; width: min(400px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 34px; line-height: 1.1; margin: 4px 0 8px; }
.auth-card p { margin: 0 0 20px; }
.alert { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }

/* Drop zone & toasts */
.dropzone { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; background: color-mix(in srgb, var(--accent) 18%, transparent); backdrop-filter: blur(2px); pointer-events: none; }
.dropzone.on { display: grid; }
.dropzone div { padding: 26px 40px; border: 2px dashed var(--accent); border-radius: 20px; background: var(--card); font-family: Fraunces, serif; font-size: 24px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(340px, calc(100vw - 40px)); }
.toast { background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); }
.toast.err { background: var(--danger); color: #fff; }
.toast .bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.25); margin-top: 8px; overflow: hidden; }
.toast .bar i { display: block; height: 100%; background: currentColor; width: 0; transition: width .2s; }

/* Mobile */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 24px 16px 110px; }
  .tabbar { display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 50; background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 6px; justify-content: space-around; }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 4px; font-size: 11px; text-decoration: none; color: var(--muted); border-radius: 16px; font-weight: 500; }
  .tabbar a.active { color: var(--accent); background: var(--accent-soft); }
  .row { grid-template-columns: 36px 1fr 36px; }
  .row .size, .row .date { display: none; }
  .search { max-width: none; order: 3; flex-basis: 100%; }
  .toasts { bottom: 96px; }
  .editor-title { padding: 18px 18px 6px; }
  .editor { padding: 16px 18px 30px; }
  .toolbar { padding: 6px 10px; }
  .field-row { grid-template-columns: 1fr; }
  .leaves { width: 220px; height: 220px; }
}

/* ---------- v2 ---------- */
.btn.small { padding: 5px 11px; font-size: 12.5px; gap: 6px; }
.btn.small svg { width: 15px; height: 15px; }
.tile-arrow { width: 16px; height: 16px; color: var(--muted); }
.folder-tile { min-height: 120px; }
.folder-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.folder-ico svg { width: 21px; height: 21px; }

/* Tree */
.tree { padding: 6px; }
.trow { display: grid; grid-template-columns: 20px 32px 1fr auto 34px; align-items: center; gap: 8px; padding: 6px 6px 6px calc(8px + var(--d) * 22px); border-radius: 10px; cursor: pointer; min-height: 46px; }
.trow:hover { background: var(--card-2); }
.trow .ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--card-2); border: 1px solid var(--line); }
.trow .ico svg { width: 16px; height: 16px; }
.trow .ico.folder { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.trow .ico.note { color: #6b5fb0; }
.trow .ico.pdf { color: #b6473a; }
.trow .ico.audio { color: #2f7d93; }
.trow .ico.image { color: #a2722b; }
.troot .tname { font-family: Fraunces, Georgia, serif; font-size: 19px; }
.tname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.tname small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.tmeta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tchev { display: grid; place-items: center; color: var(--muted); transition: transform .15s; }
.tchev svg { width: 16px; height: 16px; }
.tchev.open { transform: rotate(90deg); }
.tchev.hide { visibility: hidden; }
.tkids { position: relative; }
.tempty { padding: 6px 0 8px calc(60px + var(--d) * 22px); color: var(--muted); font-size: 13px; }

/* Quick notes */
.rapide { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 16px; align-items: start; }
.r-list { padding: 18px 14px 10px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 20px; max-height: calc(100vh - 60px); }
.r-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; padding: 0 4px; }
.r-head h1 { font-size: 32px; margin: 0; line-height: 1.05; }
.r-paste { min-height: 52px; padding: 14px; border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 14px; background: var(--accent-soft); outline: none; font-size: 14px; color: var(--text); cursor: text; }
.r-paste:empty::before { content: attr(data-placeholder); color: var(--accent); }
.r-paste:focus { border-style: solid; border-color: var(--accent); }
.r-search { max-width: none; }
.r-items { overflow: auto; margin: 0 -4px; padding: 0 4px 6px; min-height: 0; }
.r-group { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 12px 10px 6px; }
.r-item { display: block; position: relative; padding: 10px 12px; border-radius: 12px; text-decoration: none; border-bottom: 1px solid var(--line); }
.r-item:hover { background: var(--card-2); }
.r-item.active { background: color-mix(in srgb, var(--warn) 22%, var(--card)); border-color: transparent; }
.r-item b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 36px; }
.r-line { display: flex; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.r-time { flex: none; color: var(--text); opacity: .75; }
.r-snip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.r-att { position: absolute; right: 12px; top: 11px; display: flex; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); }
.r-att svg { width: 14px; height: 14px; }
.r-empty { color: var(--muted); font-size: 14px; padding: 18px 8px; text-align: center; }
.r-detail { overflow: hidden; min-height: 70vh; min-width: 0; }
.r-toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.r-toolbar .r-date { margin-left: auto; color: var(--muted); font-size: 13px; }
.r-back { display: none; }
.r-editor { min-height: 60vh; }
.r-editor > div:first-child, .r-editor > p:first-child { font-family: Fraunces, Georgia, serif; font-size: 26px; line-height: 1.25; }
.r-none { display: grid; place-items: center; text-align: center; padding: 80px 24px; gap: 4px; }
.r-none h3 { font-size: 24px; margin: 10px 0 0; }
.r-none .brand-mark { margin: 0; }

/* Attachments inside notes */
.att { display: block; margin: 12px 0; user-select: none; }
.att-img img { display: block; max-width: min(100%, 520px); border-radius: 12px; border: 1px solid var(--line); cursor: zoom-in; }
.att-audio { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card-2); max-width: 520px; }
.att-audio audio { width: 100%; margin-top: 8px; }
.att-name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.att-name svg { width: 17px; height: 17px; color: #2f7d93; flex: none; }
.att-file { display: inline-flex !important; align-items: center; gap: 12px; padding: 10px 16px 10px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--card-2); text-decoration: none; max-width: 100%; cursor: pointer; }
.att-file:hover { border-color: var(--accent); }
.att-file .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); flex: none; }
.att-file .ico svg { width: 20px; height: 20px; }
.att-file .ico.pdf { color: #b6473a; }
.att-meta { display: flex; flex-direction: column; min-width: 0; }
.att-meta b { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta small { color: var(--muted); font-size: 12px; }
.att-pending { display: inline-block; padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; }
.toolbar button svg { width: 16px; height: 16px; vertical-align: middle; }

@media (max-width: 820px) {
  .rapide { grid-template-columns: 1fr; }
  .r-list { position: static; max-height: none; }
  .rapide.has-note .r-list { display: none; }
  .rapide:not(.has-note) .r-detail { display: none; }
  .r-back { display: inline-flex; }
  .r-toolbar .r-date { display: none; }
  .r-toolbar .save-state { margin-left: auto; }
  .trow { grid-template-columns: 18px 30px 1fr auto 32px; gap: 6px; padding-left: calc(4px + var(--d) * 14px); }
  .tempty { padding-left: calc(52px + var(--d) * 14px); }
  .tabbar a { font-size: 10.5px; padding: 7px 2px; }
}
.rapide > * { min-width: 0; }
@media (max-width: 820px) {
  .r-search { order: 0; flex-basis: auto; }
}

/* ---------- v3 ---------- */
.wordmark { display: inline-flex; align-items: center; gap: 12px; font-family: Fraunces, Georgia, serif; font-size: 26px; font-weight: 500; letter-spacing: -0.01em; }
.wordmark .brand-mark { width: 44px; height: 44px; font-size: 26px; border-radius: 13px; }
.auth-card .wordmark { margin-bottom: 18px; }
.folder-pick button { display: flex; align-items: center; gap: 9px; }
.folder-pick button svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.pick-head { padding: 10px 12px 4px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); background: var(--card-2); border-bottom: 1px solid var(--line); }
.pick-empty { padding: 9px 12px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }
.conn-field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 14px; }
.conn-field .eyebrow { flex-basis: 100%; margin: 0; }
.conn-field code { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 10px 12px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); font-size: 13px; }
.conn-steps { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 6px; }
.conn-more { margin-bottom: 12px; }
.conn-more summary { cursor: pointer; font-weight: 500; margin-bottom: 8px; }
.conn-more code { font-size: 12.5px; }
.conn-warn { font-size: 13px; }
@media (max-width: 820px) {
  .r-toolbar { flex-wrap: wrap; }
  .r-toolbar [data-moverapid] { order: 5; }
}

/* ---------- v4 ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { touch-action: manipulation; }
.title-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.title-row h1 { min-width: 0; overflow-wrap: anywhere; }
.title-row .icon-btn { flex: none; margin-top: 4px; }

/* Swipe rows */
.swipe { position: relative; overflow: hidden; }
.swipe-act { position: absolute; top: 0; right: 0; bottom: 0; width: 176px; display: flex; }
.swipe-act button { flex: 1; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; color: #fff; cursor: pointer; }
.swipe-act button svg { width: 19px; height: 19px; }
.sw-archive, .sw-restore { background: #c28a2e; }
.sw-delete { background: #c0412f; }
.swipe-face { position: relative; z-index: 1; background: var(--card); transition: transform .22s ease; will-change: transform; }
.list .swipe { border-bottom: 1px solid var(--line); }
.list .swipe:last-child { border-bottom: 0; }
.list .row { border-bottom: 0; }
.list .row:hover, .row.swipe-face:hover { background: var(--card-2); }
.tree .swipe { border-radius: 10px; }
.tree .trow.swipe-face:hover { background: var(--card-2); }
.r-items .swipe { border-radius: 12px; border-bottom: 1px solid var(--line); }
.r-items .r-item { border-bottom: 0; border-radius: 12px; }
.r-items .r-item:hover { background: var(--card-2); }
.r-items .r-item.active { background: color-mix(in srgb, var(--warn) 22%, var(--card)); }
@media (hover: hover) and (pointer: fine) { .swipe-act { display: none; } }

/* PDF viewer */
.pdfv { padding: 0; overflow: hidden; }
.pdf-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--card-2); }
.pdf-group { display: flex; align-items: center; gap: 4px; }
.pdf-bar .icon-btn { font-size: 20px; font-weight: 600; color: var(--text); }
.pdf-page-n { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pdf-page-n input { width: 54px; padding: 6px 4px; text-align: center; font-size: 16px; -moz-appearance: textfield; }
.pdf-page-n input::-webkit-outer-spin-button, .pdf-page-n input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pdf-pct { min-width: 92px; text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pdf-bar .btn.small.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pdf-scroll { position: relative; overflow: auto; background: color-mix(in srgb, var(--bg-2) 70%, #000 4%); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px; width: max-content; min-width: 100%; box-sizing: border-box; transform-origin: top center; }
.pdf-page { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 4px 14px rgba(0,0,0,.08); border-radius: 2px; flex: none; }
.pdf-page canvas { display: block; border-radius: 2px; }
.pdf-loading { padding: 40px 20px; color: var(--muted); text-align: center; }

@media (max-width: 820px) {
  input, select, textarea, .editor, .r-paste, .r-editor, [contenteditable] { font-size: 16px !important; }
  .search input { font-size: 16px; }
  .r-editor > div:first-child, .r-editor > p:first-child { font-size: 24px !important; }
  .pdf-bar { padding: 6px 8px; gap: 6px; }
  .pdf-pct { min-width: 0; font-size: 12px; }
  .pdf-bar .btn.small { padding: 5px 9px; }
  .page-head .actions { width: 100%; }
}
.file-title h1 { font-size: clamp(24px, 4vw, 36px); word-break: break-word; }
.l-short { display: none; }
@media (max-width: 820px) {
  .crumbs { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
  .crumbs > * { flex: none; }
  .crumbs > :last-child { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .file-title .eyebrow { display: none; }
  .file-title h1 { font-size: 22px; }
  .file-actions { flex-wrap: nowrap; }
  .file-actions .btn { padding: 7px 12px; font-size: 13px; }
  .page-head:has(.file-title) { margin-bottom: 12px; gap: 10px; }
  .l-long { display: none; }
  .l-short { display: inline; }
  .pdf-pct { display: none; }
  .pdf-bar { flex-wrap: nowrap; }
}
.pdfv { overflow: clip; }
.pdf-bar { overflow-x: auto; scrollbar-width: none; }
.pdf-bar::-webkit-scrollbar { display: none; }
.pdf-bar .btn.small svg { width: 16px; height: 16px; }
@media (max-width: 820px) {
  .pdf-bar .btn.small { padding: 6px 9px; }
  .pdf-bar .icon-btn { width: 34px; height: 34px; }
  .pdf-page-n input { width: 46px; }
}

/* ---------- v5: calendario, backup, spazio ---------- */
:root, :root[data-theme="light"] { --k-esame: #c4822a; --k-scadenza: #b8442f; --k-lezione: #3c6a49; --k-altro: #6b6f9e; }
:root[data-theme="dark"] { --k-esame: #e0b060; --k-scadenza: #e2785f; --k-lezione: #8cc296; --k-altro: #a3a8e0; }
:root[data-theme="sepia"] { --k-esame: #a8741f; --k-scadenza: #9e3a22; --k-lezione: #5f6b2e; --k-altro: #6c5c8a; }
.k-esame { --k: var(--k-esame); } .k-scadenza { --k: var(--k-scadenza); }
.k-lezione, .k-laboratorio, .k-tirocinio, .k-seminario { --k: var(--k-lezione); } .k-altro { --k: var(--k-altro); }

.cal-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.cal-month { padding: 16px; }
.cal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.cal-head h2 { flex: 1; margin: 0; font-size: 24px; text-align: center; }
.cal-wd, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd span { text-align: center; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 4px 0; }
.cal-day { min-height: 92px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); display: flex; flex-direction: column; gap: 4px; cursor: pointer; text-align: left; min-width: 0; color: var(--text); }
.cal-day:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.cal-day.other { background: transparent; color: var(--muted); border-color: transparent; }
.cal-day.today .cal-n { background: var(--accent); color: var(--accent-ink); }
.cal-day.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-evs { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-ev { display: block; font-size: 11.5px; line-height: 1.3; padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, var(--k) 16%, transparent); color: var(--k); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 6px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; font-size: 12.5px; color: var(--muted); align-items: center; }
.cal-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--k); margin-right: 6px; vertical-align: 1px; }
.cal-toggle { flex-direction: row; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--muted); cursor: pointer; }
.cal-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.cal-legend .cal-toggle { margin-left: auto; }
.cal-side { display: grid; gap: 16px; }
.cal-panel { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.cal-panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cal-panel-head h3 { margin: 0; font-size: 21px; }
.cal-panel-head .eyebrow { margin: 0; }
.cal-none { margin: 6px 0; font-size: 14px; }
.ev-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 8px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; text-align: left; color: var(--text); }
.ev-row:hover { background: var(--card-2); }
.ev-bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--k); flex: none; }
.ev-date { display: flex; flex-direction: column; align-items: center; width: 34px; flex: none; line-height: 1.1; }
.ev-date b { font-family: Fraunces, Georgia, serif; font-size: 20px; font-weight: 500; }
.ev-date small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ev-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ev-main b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-main small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-row .chip { flex: none; }
textarea { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); color: var(--text); font-size: 15px; outline: none; width: 100%; resize: vertical; font-family: inherit; }
.modal .foot { flex-wrap: wrap; }

/* Backup */
.bk-list { display: flex; flex-direction: column; }
.bk-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.bk-row:first-child { border-top: 0; }
.bk-main { flex: 1; min-width: 0; }
.bk-when { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bk-label { font-weight: 600; overflow-wrap: anywhere; }
.bk-counts { font-size: 12.5px; color: var(--muted); }
.bk-actions { display: flex; gap: 6px; flex: none; }
.bk-missing { max-height: 160px; overflow: auto; font-size: 14px; }

/* Spazio */
.meter { height: 12px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter.warn i { background: var(--warn); }
.meter.crit i { background: var(--danger); }
.meter-legend { display: flex; justify-content: space-between; gap: 10px; margin: 8px 0 12px; font-variant-numeric: tabular-nums; }
.meter-legend b { font-family: Fraunces, Georgia, serif; font-size: 20px; font-weight: 500; }
.warn-text { color: var(--warn) !important; }
.store-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 6px 0 14px; }
.store-grid div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.store-grid span { color: var(--muted); }
.store-grid b { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.limit-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.limit-form label { margin: 0; flex: 1; min-width: 160px; }
.small-note { font-size: 12.5px; margin-top: 10px !important; }

@media (max-width: 1000px) { .cal-layout { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .cal-month { padding: 10px; }
  .cal-day { min-height: 52px; padding: 4px 2px; align-items: center; gap: 3px; border-radius: 10px; }
  .cal-n { width: 24px; height: 24px; font-size: 13px; }
  .cal-evs { flex-direction: row; justify-content: center; gap: 3px; }
  .cal-ev { width: 6px; height: 6px; padding: 0; border-radius: 50%; font-size: 0; background: var(--k); }
  .cal-more { display: none; }
  .cal-legend .cal-toggle { margin-left: 0; }
  .store-grid { grid-template-columns: 1fr; }
  .bk-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .tabbar a { font-size: 9.5px; padding: 7px 1px; letter-spacing: -0.01em; }
  .tabbar svg { width: 19px; height: 19px; }
}
@media (max-width: 1000px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr); }
  .cal-layout > *, .cal-month, .cal-panel { min-width: 0; }
}
@media (max-width: 820px) {
  .cal-head h2 { font-size: 20px; }
  .cal-wd span { font-size: 10.5px; letter-spacing: 0; }
}

/* ---------- v6: barra a 7 voci ---------- */
.nav a.ext::after { content: "↗"; margin-left: auto; font-size: 12px; opacity: .6; }
@media (max-width: 820px) {
  .tabbar { padding: 5px 4px; gap: 1px; }
  .tabbar a { min-width: 0; padding: 6px 1px 5px; gap: 3px; font-size: 9.5px; line-height: 1.1; letter-spacing: -0.02em; border-radius: 14px; }
  .tabbar a span { text-align: center; overflow-wrap: anywhere; hyphens: none; max-width: 100%; }
  .tabbar svg { width: 19px; height: 19px; }
  .main { padding-bottom: 130px; }
}
@media (max-width: 360px) {
  .tabbar a { font-size: 8.5px; }
  .tabbar svg { width: 17px; height: 17px; }
}
.cal-layout > *, .cal-side, .cal-panel, .cal-month { min-width: 0; }
.ev-row .chip { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 820px) {
  .tabbar a { justify-content: flex-start; }
  .tabbar a:first-child { flex: 1.35; }
  .tabbar a span { white-space: nowrap; overflow-wrap: normal; }
}

/* ---------- v7: Link calendario, impostazioni a tendina ---------- */
.lc-panel { padding: 16px; margin-bottom: 22px; }
.lc-panel:empty { min-height: 74px; }
.lc-panel.full { margin-top: 4px; }
.lc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; }
.lc-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.lc-title > svg { width: 38px; height: 38px; padding: 9px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex: none; }
.lc-title h3 { margin: 0; font-size: 20px; line-height: 1.15; }
.lc-title small { color: var(--muted); font-size: 13px; }
.lc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.lc-empty { margin: 12px 0 0; color: var(--muted); font-size: 14px; max-width: 62ch; }
.lc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-top: 14px; }
.lc-grid .swipe { border-radius: 14px; }
.lc-tile { display: flex; align-items: center; gap: 12px; padding: 8px 6px 8px 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); cursor: pointer; min-width: 0; }
.lc-tile:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.lc-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lc-thumb { width: 52px; height: 52px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--card-2); border: 1px solid var(--line); overflow: hidden; }
.lc-thumb svg { width: 22px; height: 22px; }
.lc-thumb.img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lc-thumb.pdf { color: #b6473a; }
.lc-thumb.link { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.lc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lc-info b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-info small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .ico.link { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

.lc-quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.lc-quick-btn { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); text-decoration: none; min-width: 0; box-shadow: var(--shadow); }
.lc-quick-btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.lc-quick-btn > svg:first-child { width: 36px; height: 36px; padding: 8px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); flex: none; }
.lc-quick-btn > svg:last-child { width: 16px; height: 16px; color: var(--muted); flex: none; margin-left: auto; }
.lc-quick-btn span { display: flex; flex-direction: column; min-width: 0; }
.lc-quick-btn b { font-weight: 600; }
.lc-quick-btn small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.settings { gap: 10px; }
.acc { padding: 0 !important; overflow: hidden; }
.acc > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 16px 20px; cursor: pointer; user-select: none; }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary:hover { background: var(--card-2); }
.acc-title { flex: 1; font-family: Fraunces, Georgia, serif; font-size: 20px; }
.acc-chev { width: 18px; height: 18px; color: var(--muted); transition: transform .2s; }
.acc[open] > summary .acc-chev { transform: rotate(90deg); }
.acc[open] > summary { border-bottom: 1px solid var(--line); }
.acc-body { padding: 16px 20px 20px; }
.acc > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

@media (max-width: 820px) {
  .lc-panel { padding: 12px; }
  .lc-grid { grid-template-columns: 1fr; }
  .lc-quick { gap: 8px; }
  .lc-quick-btn { padding: 10px; gap: 9px; }
  .lc-quick-btn > svg:first-child { width: 32px; height: 32px; padding: 7px; }
  .lc-quick-btn > svg:last-child { display: none; }
  .acc > summary { padding: 14px 16px; }
  .acc-body { padding: 14px 16px 16px; }
}
.swipe:not(.swiping) > .swipe-act { visibility: hidden; }

/* ---------- v8 ---------- */
.up-top, .up-sec { margin-bottom: 16px; }
.up-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 2px 14px; }
.up-list .ev-row[hidden] { display: none; }
.lc-open { flex: none; background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.lc-open:hover { background: var(--accent); filter: brightness(1.06); }
@media (max-width: 820px) {
  .up-list { grid-template-columns: 1fr; }
  .lc-open { padding: 6px 10px; }
}
.up-list { grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }
.up-list > * { min-width: 0; }
.lc-tile.has-open { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; grid-template-areas: "thumb info menu" "thumb open menu"; column-gap: 12px; row-gap: 6px; align-items: center; }
.lc-tile.has-open .lc-thumb { grid-area: thumb; }
.lc-tile.has-open .lc-info { grid-area: info; align-self: end; }
.lc-tile.has-open .lc-open { grid-area: open; justify-self: start; align-self: start; }
.lc-tile.has-open .lc-btns { grid-area: menu; }
@media (max-width: 820px) { .up-list { grid-template-columns: minmax(0, 1fr); } }

/* ---------- v9 ---------- */
.row { grid-template-columns: 40px 1fr auto auto auto; }
.row-btns, .lc-btns { display: flex; align-items: center; gap: 0; flex: none; }
.tabbar a, .nav a { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* Sfondi */
.bg-photo { position: fixed; inset: 0; z-index: 0; background-size: cover; background-position: center; display: none; pointer-events: none; }
.bg-photo::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 58%, transparent); }
:root[data-bg="photo"] .bg-photo { display: block; }
:root[data-bg]:not([data-bg="leaves"]) .leaves { display: none; }
:root[data-bg="lines"] body { background-image: repeating-linear-gradient(to bottom, transparent 0 31px, color-mix(in srgb, var(--line) 85%, transparent) 31px 32px); background-attachment: fixed; }
:root[data-bg="dots"] body { background-image: radial-gradient(color-mix(in srgb, var(--muted) 35%, transparent) 1.2px, transparent 1.6px); background-size: 22px 22px; background-attachment: fixed; }
:root[data-bg="grid"] body { background-image: linear-gradient(color-mix(in srgb, var(--line) 80%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--line) 80%, transparent) 1px, transparent 1px); background-size: 24px 24px; background-attachment: fixed; }
:root[data-bg="soft"] body { background-image: radial-gradient(60vw 50vh at 10% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%), radial-gradient(50vw 50vh at 100% 100%, color-mix(in srgb, var(--warn) 14%, transparent), transparent 70%); background-attachment: fixed; }
:root[data-bg] .sidebar { background: color-mix(in srgb, var(--bg) 90%, var(--card)); }
.bgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.bg-opt { border: 2px solid var(--line); border-radius: 14px; padding: 6px; background: transparent; cursor: pointer; display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: left; color: var(--text); }
.bg-opt.active { border-color: var(--accent); }
.bg-opt b { font-size: 13px; font-weight: 600; padding: 0 2px 2px; }
.bg-sw { height: 46px; border-radius: 9px; background-color: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.bg-sw svg { width: 20px; height: 20px; }
.bgsw-leaves { background-image: radial-gradient(circle at 80% 20%, color-mix(in srgb, var(--leaf) 45%, transparent) 0 9px, transparent 10px), radial-gradient(circle at 65% 40%, color-mix(in srgb, var(--leaf) 35%, transparent) 0 7px, transparent 8px); }
.bgsw-lines { background-image: repeating-linear-gradient(to bottom, transparent 0 9px, var(--line) 9px 10px); }
.bgsw-dots { background-image: radial-gradient(color-mix(in srgb, var(--muted) 45%, transparent) 1.2px, transparent 1.6px); background-size: 9px 9px; }
.bgsw-grid { background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 9px 9px; }
.bgsw-soft { background-image: radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 60%), radial-gradient(circle at 100% 100%, color-mix(in srgb, var(--warn) 28%, transparent), transparent 60%); }

/* Idee */
.ideas-box { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card); }
.ideas-box .toolbar { position: static; padding: 6px 10px; align-items: center; }
.ideas-ed { min-height: 180px; max-height: 55vh; overflow: auto; padding: 14px 16px; font-size: 15px; }

/* Barra vista cartella */
.view-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button svg { width: 15px; height: 15px; }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* Griglia */
.ggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.gtile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; min-width: 0; box-shadow: var(--shadow); }
.gtile:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.gtile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gthumb { position: relative; aspect-ratio: 1 / 1; background: var(--card-2); display: grid; place-items: center; overflow: hidden; }
.gthumb img, .gthumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.gplay { position: absolute; width: 38px; height: 38px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; font-size: 14px; padding-left: 3px; }
.gicon svg { width: 42px; height: 42px; }
.gicon.folder { color: var(--accent); } .gicon.pdf { color: #b6473a; } .gicon.audio { color: #2f7d93; } .gicon.note { color: #6b5fb0; } .gicon.word { color: #2b5797; } .gicon.slides { color: #c4572d; } .gicon.sheet { color: #217346; }
.gmeta { display: flex; align-items: center; gap: 0; padding: 6px 2px 6px 10px; min-width: 0; }
.gname { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gname b { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gname small { color: var(--muted); font-size: 12px; }
.gmeta .icon-btn { width: 32px; height: 32px; flex: none; }
.row .ico.word { color: #2b5797; } .row .ico.slides { color: #c4572d; } .row .ico.sheet { color: #217346; }

/* Galleria */
body.g-open { overflow: hidden; }
.gallery { position: fixed; inset: 0; z-index: 95; background: #0c0d0c; color: #f1f1ec; display: flex; flex-direction: column; touch-action: none; }
.g-top { display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 8px max(10px, env(safe-area-inset-left, 0px)); background: linear-gradient(rgba(0,0,0,.55), transparent); position: relative; z-index: 2; }
.g-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.g-title b { font-weight: 600; font-size: 15px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-title small { font-size: 12px; opacity: .7; font-variant-numeric: tabular-nums; }
.g-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.g-btn svg { width: 20px; height: 20px; }
.g-stage { flex: 1; position: relative; overflow: hidden; }
.g-track { position: absolute; inset: 0; display: flex; will-change: transform; }
.g-slide { flex: 0 0 100%; height: 100%; display: grid; place-items: center; padding: 8px 8px calc(16px + env(safe-area-inset-bottom, 0px)); overflow: hidden; }
.g-slide img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; transition: transform .15s ease; transform-origin: center; }
.g-slide video { max-width: 100%; max-height: 100%; background: #000; }
.g-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; cursor: pointer; z-index: 2; }
.g-nav svg { width: 24px; height: 24px; }
.g-nav.prev { left: max(14px, env(safe-area-inset-left, 0px)); }
.g-nav.next { right: max(14px, env(safe-area-inset-right, 0px)); }
.g-nav[hidden] { display: none; }

/* Foto nella vista file */
.img-view { padding: 10px; display: grid; place-items: center; background: var(--card-2); }
.img-view img { max-width: 100%; max-height: calc(100vh - 280px); object-fit: contain; border-radius: 8px; cursor: zoom-in; display: block; }

/* Riordina */
.modal.reorder { width: min(520px, 100%); }
.ro-list { max-height: 55vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.ro-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 4px; border-bottom: 1px solid var(--line); background: var(--card); }
.ro-row:last-child { border-bottom: 0; }
.ro-row.drag { background: var(--accent-soft); box-shadow: 0 6px 18px rgba(0,0,0,.15); position: relative; z-index: 1; }
.ro-grip { width: 34px; height: 38px; display: grid; place-items: center; color: var(--muted); cursor: grab; touch-action: none; flex: none; }
.ro-grip svg { width: 18px; height: 18px; }
.ro-row .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--card-2); flex: none; }
.ro-row .ico svg { width: 16px; height: 16px; }
.ro-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.ro-row .icon-btn { width: 32px; height: 32px; }

/* Office */
.office { padding: 0; overflow: hidden; }
.office-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); background: var(--card-2); }
.office-frame iframe { width: 100%; height: 75vh; border: 0; display: block; background: #fff; }
.pad { padding: 16px; } .pad-x { padding: 0 16px 14px; }
.doc-page { background: var(--card-2); padding: 18px 12px; }
.doc-body { max-width: 760px; margin: 0 auto; background: #fff; color: #1d1d1b; padding: 40px 44px; min-height: 60vh; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.1), 0 6px 20px rgba(0,0,0,.06); font: 15px/1.6 "Times New Roman", Georgia, serif; overflow-wrap: anywhere; }
.doc-body h1, .doc-body h2, .doc-body h3 { font-family: inherit; color: #1d1d1b; }
.doc-body img { max-width: 100%; height: auto; }
.doc-body table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.doc-body td, .doc-body th { border: 1px solid #ccc; padding: 4px 6px; vertical-align: top; }
.doc-body.editor { outline: none; }
.doc-title { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.doc-title svg { width: 22px; height: 22px; color: #2b5797; }
.doc-title b { font-weight: 600; overflow-wrap: anywhere; }

/* Eventi: penna per modificare */
.ev-row { cursor: default; }
.ev-row:hover { background: transparent; }
.ev-pen { flex: none; width: 34px; height: 34px; }

/* Personalizza menu */
.icon-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin-bottom: 8px; }
.icon-pick button { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); display: grid; place-items: center; cursor: pointer; color: var(--text); }
.icon-pick button svg { width: 20px; height: 20px; }
.icon-pick button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

@media (max-width: 820px) {
  .row { grid-template-columns: 36px 1fr auto; }
  .ggrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .doc-body { padding: 22px 18px; font-size: 16px; }
  .doc-page { padding: 10px 6px; }
  .office-frame iframe { height: 70vh; }
  .g-nav { display: none; }
  .ev-pen { width: 32px; height: 32px; }
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 32px 0 12px; }
.section-head .section-title { margin: 0; }
.section-head .view-bar { margin: 0; }
