@font-face { font-family: "DM Sans"; src: url("/fonts/DMSans-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/fonts/DMSans-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/fonts/DMSans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* Brandsteinin värit: lähes musta, punainen korostus, kerma paperina. */
:root {
  --paper: #f3f1ec;
  --dot: #d7d3ca;
  --card: #ffffff;
  --ink: #141414;
  --ink-soft: #4a4842;
  --ink-mute: #8a877f;
  --line: #e4e0d7;
  --accent: #c42032;
  --accent-ink: #ffffff;
  --select: #2f6fdf;
  --shadow: 0 1px 2px rgb(20 20 20 / 0.08), 0 2px 8px rgb(20 20 20 / 0.06);
  --shadow-lift: 0 8px 28px rgb(20 20 20 / 0.18);
  --chrome: rgb(255 255 255 / 0.92);
  --radius: 6px;
  --font: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --c-yellow: #fff3b0; --c-orange: #ffd9b3; --c-red: #ffc9c9; --c-pink: #ffd3ea; --c-purple: #e4d5ff;
  --c-blue: #cfe2ff; --c-teal: #c7f0ea; --c-green: #d3f2c8; --c-gray: #e6e4df; --c-dark: #23221f;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1a1918; --dot: #33312d; --card: #262522; --ink: #f1eee8; --ink-soft: #c9c5bc; --ink-mute: #8f8b82;
    --line: #3a3833; --chrome: rgb(38 37 34 / 0.94); --select: #6b9cff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 2px 8px rgb(0 0 0 / 0.3); --shadow-lift: 0 10px 30px rgb(0 0 0 / 0.5);
    --c-yellow: #4d4419; --c-orange: #553719; --c-red: #5a2228; --c-pink: #552540; --c-purple: #3d2f5c;
    --c-blue: #213a5c; --c-teal: #1c4741; --c-green: #27452a; --c-gray: #383631; --c-dark: #0d0d0c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1a1918; --dot: #33312d; --card: #262522; --ink: #f1eee8; --ink-soft: #c9c5bc; --ink-mute: #8f8b82;
  --line: #3a3833; --chrome: rgb(38 37 34 / 0.94); --select: #6b9cff;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 2px 8px rgb(0 0 0 / 0.3); --shadow-lift: 0 10px 30px rgb(0 0 0 / 0.5);
  --c-yellow: #4d4419; --c-orange: #553719; --c-red: #5a2228; --c-pink: #552540; --c-purple: #3d2f5c;
  --c-blue: #213a5c; --c-teal: #1c4741; --c-green: #27452a; --c-gray: #383631; --c-dark: #0d0d0c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd { font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 3px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--card); }
a { color: inherit; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 9px 18px; font-weight: 500; }
.btn:hover { border-color: var(--ink-mute); }
.btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--small { padding: 5px 12px; font-size: 13px; }
.btn--danger { color: var(--accent); border-color: currentColor; }
.btn:disabled { opacity: 0.5; cursor: default; }
.iconbtn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; font-size: 18px; }
.iconbtn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.iconbtn svg, .tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool svg .fill { fill: currentColor; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink-soft); margin-left: 8px; }

/* ------------------------------------------------------------------ kirjautuminen */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; overflow: auto; }
.login__card { width: min(400px, 100%); background: var(--card); border-radius: 18px; padding: 36px 32px; box-shadow: var(--shadow); }
.login__logo { display: block; margin-bottom: 18px; border-radius: 10px; }
.login__title { margin: 0 0 8px; font-size: 26px; letter-spacing: -0.01em; }
.login__lead { margin: 0 0 22px; color: var(--ink-soft); }
.login__form { display: grid; gap: 12px; }
.login__note { margin: 16px 0 0; font-size: 14px; color: var(--ink-soft); min-height: 1em; }
.field { display: grid; gap: 6px; }
.field__label { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.field input, .share input, .share select, .search__input, .import input[type=file] {
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; background: var(--paper); width: 100%; outline: none;
}
.field input:focus, .share input:focus, .search__input:focus { border-color: var(--ink); }
#login-code-input { font: 700 26px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.3em; text-align: center; }

/* ------------------------------------------------------------------ kehys */
.app { position: fixed; inset: 0; }
.topbar { position: absolute; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px 0 16px; background: var(--chrome); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); z-index: 50; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.crumbs__link { text-decoration: none; color: var(--ink-mute); overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.crumbs__link:hover { color: var(--ink); }
.crumbs__sep { color: var(--ink-mute); }
.crumbs__current { font-weight: 700; font-size: 16px; padding: 3px 6px; border-radius: 6px; outline: none; overflow: hidden; text-overflow: ellipsis; }
.crumbs__current[contenteditable]:hover, .crumbs__current:focus { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.crumbs__shared { margin-left: 10px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.topbar__right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.status { font-size: 12px; color: var(--ink-mute); margin-right: 6px; white-space: nowrap; }
.status[data-status="offline"] { color: var(--accent); }
.presence { display: flex; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; border: 2px solid var(--card); margin-left: -6px; }
.avatar--small { width: 22px; height: 22px; font-size: 10px; margin: 0; border: 0; }

.toolbar { position: absolute; top: 64px; left: 12px; z-index: 40; display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--chrome); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); backdrop-filter: blur(10px); max-height: calc(100% - 140px); overflow-y: auto; scrollbar-width: none; }
.toolbar hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.tool { display: grid; justify-items: center; gap: 2px; width: 62px; padding: 7px 2px 6px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); font-size: 10.5px; touch-action: none; user-select: none; }
.tool:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.tool.is-active { background: var(--ink); color: var(--paper); }
.tool--draw.is-active { background: var(--accent); color: #fff; }

.drawbar { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--chrome); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.drawbar__group { display: flex; gap: 4px; align-items: center; }
.drawbar__pen { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; display: grid; place-items: center; }
.drawbar__pen svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.drawbar__pen.is-active { background: var(--ink); color: var(--paper); }
.drawbar__color { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); padding: 0; }
.drawbar__color.is-active { outline: 2px solid var(--ink); outline-offset: 2px; }
.drawbar__size input { width: 90px; accent-color: var(--ink); }

/* ------------------------------------------------------------------ kangas */
.viewport { position: absolute; inset: 52px 0 0 0; overflow: hidden; touch-action: none; outline: none;
  background-color: var(--paper); background-image: radial-gradient(var(--dot) 1.1px, transparent 1.3px); }
.viewport.is-panning, .viewport.is-panning-ready { cursor: grab; }
.viewport.is-panning { cursor: grabbing; }
.viewport[data-tool="line"] { cursor: crosshair; }
.viewport[data-tool^="draw-"] { cursor: crosshair; }
.viewport[data-tool="draw-eraser"] { cursor: cell; }
.viewport[data-tool^="draw-"] .layer--cards, .viewport[data-tool="line"] .card * { pointer-events: none; }
.viewport.is-dropping { box-shadow: inset 0 0 0 3px var(--select); }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.layer { position: absolute; left: 0; top: 0; }
.layer--lines, .layer--ink { width: 1px; height: 1px; overflow: visible; }
.layer--lines { z-index: 1; }
.layer--cards { z-index: 2; }
.layer--ink { z-index: 3; pointer-events: none; }
.layer--cursors { z-index: 4; pointer-events: none; }

.marquee { position: absolute; border: 1px solid var(--select); background: color-mix(in srgb, var(--select) 10%, transparent); pointer-events: none; z-index: 30; }
.empty { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: var(--ink-mute); pointer-events: none; max-width: 360px; padding: 0 16px; }
.empty__title { font-size: 20px; font-weight: 700; color: var(--ink-soft); margin: 0 0 6px; }

/* ------------------------------------------------------------------ kortit */
.card { position: absolute; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); user-select: none; -webkit-user-select: none; }
.card.is-selected { box-shadow: 0 0 0 2px var(--select), var(--shadow); }
.card.is-editing { user-select: text; -webkit-user-select: text; }
.card.is-dragging { box-shadow: var(--shadow-lift); opacity: 0.95; cursor: grabbing; }
.card.is-drop-target { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.card.is-flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 50%, transparent); } 100% { box-shadow: var(--shadow); } }
.card__resize { position: absolute; right: -6px; bottom: -6px; width: 18px; height: 18px; cursor: ew-resize; opacity: 0; }
.card__resize::after { content: ""; position: absolute; right: 7px; bottom: 7px; width: 7px; height: 7px; border-right: 2px solid var(--ink-mute); border-bottom: 2px solid var(--ink-mute); }
.card:hover .card__resize, .card.is-selected .card__resize { opacity: 1; }
.viewport.is-readonly .card { cursor: default; }

.c-yellow { --card: var(--c-yellow); } .c-orange { --card: var(--c-orange); } .c-red { --card: var(--c-red); }
.c-pink { --card: var(--c-pink); } .c-purple { --card: var(--c-purple); } .c-blue { --card: var(--c-blue); }
.c-teal { --card: var(--c-teal); } .c-green { --card: var(--c-green); } .c-gray { --card: var(--c-gray); }
.c-dark { --card: var(--c-dark); --ink: #f1eee8; --ink-soft: #cfcac0; --ink-mute: #8f8b82; }
.card.c-none { background: transparent; box-shadow: none; }
.card.c-none.is-selected { box-shadow: 0 0 0 2px var(--select); }

.editable { outline: none; min-height: 1.45em; word-wrap: break-word; overflow-wrap: anywhere; }
.editable:empty::before { content: attr(data-placeholder); color: var(--ink-mute); pointer-events: none; }
.rich { padding: 12px 14px; }
.rich h1 { font-size: 22px; line-height: 1.2; margin: 4px 0 6px; }
.rich h2 { font-size: 18px; line-height: 1.25; margin: 4px 0 4px; }
.rich h3 { font-size: 15px; margin: 2px 0; }
.rich ul, .rich ol { margin: 2px 0; padding-left: 20px; }
.rich blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--ink-soft); }
.rich a { color: var(--select); }
.rich code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: color-mix(in srgb, var(--ink) 8%, transparent); padding: 1px 4px; border-radius: 4px; }
.caption { font-size: 13px; color: var(--ink-soft); padding: 6px 12px 8px; }
.caption:empty { display: none; }
.card.is-editing .caption:empty, .card.is-selected .caption:empty { display: block; }

.card--heading { background: transparent; box-shadow: none; }
.card--heading.is-selected { box-shadow: 0 0 0 2px var(--select); }
.heading--l { font-size: 34px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; padding: 4px 6px; }
.heading--m { font-size: 22px; font-weight: 700; line-height: 1.2; padding: 4px 6px; }

.todo__head { display: flex; align-items: baseline; gap: 8px; padding: 12px 14px 4px; }
.todo__title { flex: 1; font-weight: 700; }
.todo__count { font-size: 12px; color: var(--ink-mute); }
.todo__progress { display: none; }
.todo__list { list-style: none; margin: 0; padding: 0 10px 10px; }
.todo__item { display: flex; gap: 8px; align-items: flex-start; padding: 3px 4px; }
.todo__check { flex-shrink: 0; width: 18px; height: 18px; margin-top: 2px; border: 1.6px solid var(--ink-mute); border-radius: 5px; background: transparent; padding: 0; position: relative; }
.todo__item.is-done .todo__check { background: var(--ink); border-color: var(--ink); }
.todo__item.is-done .todo__check::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid var(--card); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.todo__text { flex: 1; }
.todo__item.is-done .todo__text { text-decoration: line-through; color: var(--ink-mute); }

.link__empty { padding: 12px; }
.link__input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: var(--paper); outline: none; }
.link__image img, .link__play img { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; }
.link__embed { position: relative; }
.link__embed iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius) var(--radius) 0 0; }
.link__play { display: block; width: 100%; padding: 0; border: 0; background: #000; position: relative; min-height: 120px; border-radius: var(--radius) var(--radius) 0 0; }
.link__playicon { position: absolute; inset: 0; margin: auto; width: 54px; height: 54px; border-radius: 50%; background: rgb(0 0 0 / 0.65); color: #fff; display: grid; place-items: center; font-size: 20px; }
.link__meta { padding: 10px 14px 12px; display: grid; gap: 4px; }
.link__title { font-weight: 700; text-decoration: none; line-height: 1.3; overflow-wrap: anywhere; }
.link__title:hover { text-decoration: underline; }
.link__desc { margin: 0; font-size: 13px; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.link__site { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-mute); }
.link__favicon { border-radius: 3px; }

.card--image { overflow: hidden; }
.image__img { display: block; width: 100%; height: auto; background: color-mix(in srgb, var(--ink) 6%, transparent); -webkit-user-drag: none; }
.upload { padding: 18px 14px; display: grid; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.upload__bar { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) 30%, var(--line) 30%); background-size: 200% 100%; animation: load 1.1s linear infinite; }
@keyframes load { to { background-position: -200% 0; } }

.file__video, .file__audio { display: block; width: 100%; border-radius: var(--radius) var(--radius) 0 0; }
.file__audio { padding: 10px 10px 0; }
.file__row { display: flex; align-items: center; gap: 10px; padding: 12px; }
.file__icon { flex-shrink: 0; width: 40px; height: 48px; border-radius: 5px; background: var(--ink); color: var(--paper); display: grid; place-items: end center; padding-bottom: 6px; font-size: 10px; font-weight: 700; }
.file__info { flex: 1; min-width: 0; display: grid; }
.file__name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file__size { font-size: 12px; color: var(--ink-mute); }
.file__download { text-decoration: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); }

.card--board { background: transparent; box-shadow: none; text-align: center; cursor: pointer; }
.card--board.is-selected { box-shadow: none; }
.card--board.is-selected .boardcard__tile { box-shadow: 0 0 0 2px var(--select), var(--shadow); }
.card--board.is-drop-target .boardcard__tile { box-shadow: 0 0 0 3px var(--accent), var(--shadow-lift); transform: scale(1.06); }
.boardcard__tile { width: 96px; height: 96px; margin: 0 auto; border-radius: 14px; background: #141414; border: 1px solid rgb(255 255 255 / 0.08); box-shadow: var(--shadow); display: grid; place-items: center; transition: transform 0.15s; }
.boardcard__tile.c-yellow, .boardcard__tile.c-orange, .boardcard__tile.c-red, .boardcard__tile.c-pink, .boardcard__tile.c-purple,
.boardcard__tile.c-blue, .boardcard__tile.c-teal, .boardcard__tile.c-green, .boardcard__tile.c-gray { background: var(--card); }
.boardcard__tile.c-dark { background: var(--c-dark); }
.boardcard__tile.c-none { background: var(--card); border: 1px dashed var(--ink-mute); }
.card--board:hover .boardcard__tile { transform: translateY(-2px); }
.boardcard__icon { font-size: 38px; line-height: 1; }
.boardcard__tile { color: #fff; }
.boardcard__tile[class*=" c-"] { color: var(--ink-soft); }
.boardcard__icon:empty::before { content: ""; width: 34px; height: 26px; border: 2.5px solid currentColor; border-radius: 5px; display: block; }
.boardcard__title { margin-top: 8px; font-weight: 700; font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.boardcard__meta { font-size: 12px; color: var(--ink-mute); }

.card--column { background: color-mix(in srgb, var(--card) 70%, var(--paper)); }
.card--column:not([class*=" c-"]) { background: color-mix(in srgb, var(--ink) 6%, var(--paper)); box-shadow: none; }
.card--column.is-selected { box-shadow: 0 0 0 2px var(--select); }
.column__head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; }
.column__title { flex: 1; font-weight: 700; }
.column__count { font-size: 12px; color: var(--ink-mute); }
.column__body { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px 10px; min-height: 60px; }
.column__body.is-empty::after { content: "Vedä kortteja tähän"; color: var(--ink-mute); font-size: 13px; text-align: center; padding: 14px 0; border: 1.5px dashed var(--line); border-radius: var(--radius); }
.column__placeholder { height: 46px; border-radius: var(--radius); background: color-mix(in srgb, var(--select) 14%, transparent); border: 1.5px dashed var(--select); }
.card.in-column { position: relative; width: auto !important; }
.card--column > .card__resize { cursor: ew-resize; }

.card--comment { --card: #fffbe6; }
.comment__list { list-style: none; margin: 0; padding: 10px 12px 0; display: grid; gap: 10px; }
.comment__by { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.comment__by time { color: var(--ink-mute); font-size: 12px; }
.comment__del { margin-left: auto; border: 0; background: transparent; color: var(--ink-mute); font-size: 11px; }
.comment__text { margin: 4px 0 0 28px; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment__input { margin: 10px 12px 12px; padding: 8px 10px; border-radius: 8px; background: var(--paper); border: 1px solid var(--line); cursor: text; user-select: text; -webkit-user-select: text; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card--comment { --card: #3a351f; } }
:root[data-theme="dark"] .card--comment { --card: #3a351f; }

.swatch__block { display: block; height: 110px; border-radius: var(--radius) var(--radius) 0 0; position: relative; cursor: pointer; }
.swatch__picker { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.swatch__info { padding: 8px 12px 10px; display: grid; gap: 2px; }
.swatch__name { font-weight: 700; }
.swatch__hex { font-size: 12px; color: var(--ink-mute); }

.card--doc { padding: 14px 14px 12px; }
.doc__icon { font-size: 22px; }
.doc__title { font-weight: 700; font-size: 16px; margin: 4px 0; }
.doc__excerpt { margin: 0 0 10px; font-size: 13px; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

.table__wrap { overflow-x: auto; padding: 8px; }
.table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th, .table td { border: 1px solid var(--line); padding: 0; min-width: 70px; vertical-align: top; }
.table th { background: color-mix(in srgb, var(--ink) 5%, transparent); font-weight: 700; text-align: left; }
.table__cell { padding: 6px 8px; }
.table__tools { display: none; gap: 4px; padding: 0 8px 8px; }
.card.is-selected .table__tools { display: flex; }
.table__tools button { border: 1px solid var(--line); background: var(--card); border-radius: 6px; font-size: 12px; padding: 3px 8px; }

/* ------------------------------------------------------------------ viivat ja piirrokset */
.line { pointer-events: none; }
.line__hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.line__path { fill: none; stroke-linecap: round; pointer-events: none; }
.line.is-selected .line__path { stroke: var(--select) !important; }
.viewport[data-tool^="draw-"] .line__hit { pointer-events: none; }
.line-handle { fill: var(--card); stroke: var(--select); stroke-width: 2; cursor: grab; pointer-events: all; }
.line-handle--bend { fill: var(--select); }
.stroke { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.stroke--highlighter { mix-blend-mode: multiply; stroke-linecap: square; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stroke--highlighter { mix-blend-mode: screen; } }
.stroke.is-selected { filter: drop-shadow(0 0 2px var(--select)); }
.sel-outline { fill: none; stroke: var(--select); stroke-width: 1.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }

.cursor { position: absolute; left: 0; top: 0; display: flex; align-items: flex-start; gap: 2px; transition: transform 0.08s linear; }
.cursor__arrow path { fill: var(--c, #c42032); stroke: #fff; stroke-width: 1; }
.cursor__name { margin-top: 12px; background: var(--c, #c42032); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
.layer--cursors .cursor { transform-origin: 0 0; }

/* ------------------------------------------------------------------ kelluvat palkit */
.selbar, .formatbar { position: fixed; z-index: 60; display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--ink); color: var(--paper); border-radius: 10px; box-shadow: var(--shadow-lift); }
.selbar__btn { border: 0; background: transparent; color: inherit; padding: 6px 10px; border-radius: 7px; font-size: 13px; white-space: nowrap; text-decoration: none; list-style: none; cursor: pointer; }
.selbar__btn::-webkit-details-marker { display: none; }
.selbar__btn:hover, .selbar__btn.is-on { background: rgb(255 255 255 / 0.16); }
.selbar__btn--danger:hover { background: var(--accent); }
.selbar__sep { width: 1px; height: 20px; background: rgb(255 255 255 / 0.2); margin: 0 3px; }
.selbar__menu { position: relative; }
.selbar__colors, .selbar__icons { position: absolute; top: calc(100% + 8px); left: 0; display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; padding: 10px; background: var(--card); border-radius: 10px; box-shadow: var(--shadow-lift); }
.selbar__icons { grid-template-columns: repeat(6, 32px); }
.selbar__swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); padding: 0; }
.selbar__swatch.c-none { background: repeating-linear-gradient(45deg, var(--line) 0 3px, transparent 3px 7px); }
.selbar__icon { width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; font-size: 18px; color: var(--ink); }
.selbar__icon:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.formatbar button { border: 0; background: transparent; color: inherit; min-width: 30px; height: 30px; border-radius: 6px; font-size: 13px; }
.formatbar button:hover { background: rgb(255 255 255 / 0.16); }

.zoombar { position: absolute; right: 12px; bottom: 12px; z-index: 40; display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--chrome); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.zoombar__value { border: 0; background: transparent; font-size: 12px; min-width: 52px; }

.ghost { position: fixed; z-index: 100; pointer-events: none; transform: translate(-20px, -20px); width: 200px; padding: 14px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lift); font-weight: 500; opacity: 0.9; }

/* ------------------------------------------------------------------ paneelit ja modaalit */
.panel { position: absolute; top: 62px; right: 12px; bottom: 64px; width: min(380px, calc(100% - 24px)); z-index: 70; background: var(--card); border-radius: 14px; box-shadow: var(--shadow-lift); display: flex; flex-direction: column; }
.panel__head, .modal__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 18px; }
.panel__head h2, .modal__head h2 { margin: 0; font-size: 17px; }
.panel__body { padding: 4px 18px 18px; overflow-y: auto; flex: 1; }
.menu { position: absolute; top: 50px; right: 12px; z-index: 80; background: var(--card); border-radius: 12px; box-shadow: var(--shadow-lift); padding: 6px; display: grid; min-width: 250px; }
.menu button { text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 8px; }
.menu button:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.modal { position: fixed; inset: 0; z-index: 90; background: rgb(0 0 0 / 0.45); display: grid; place-items: center; padding: 16px; }
.modal__box { background: var(--card); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-lift); }
.modal--wide .modal__box { width: min(960px, 100%); height: calc(100vh - 32px); }
.modal__body { padding: 4px 20px 20px; overflow: auto; flex: 1; }
.lightbox { display: block; max-width: 100%; max-height: calc(100vh - 120px); margin: 0 auto; object-fit: contain; }

.doc-editor { display: flex; flex-direction: column; height: 100%; max-width: 760px; margin: 0 auto; }
.doc-editor__tools { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; background: var(--ink); color: var(--paper); border-radius: 10px; align-self: flex-start; margin-bottom: 14px; }
.doc-editor__tools button { border: 0; background: transparent; color: inherit; min-width: 30px; height: 30px; border-radius: 6px; }
.doc-editor__title { border: 0; outline: none; background: transparent; font-size: 32px; font-weight: 700; letter-spacing: -0.02em; padding: 0; margin-bottom: 10px; }
.doc-editor__body { flex: 1; padding: 0 0 40px; font-size: 17px; line-height: 1.65; user-select: text; -webkit-user-select: text; }

.search__input { margin-bottom: 12px; }
.search__results, .shared, .trash, .share__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.search__hit { width: 100%; text-align: left; border: 0; background: transparent; border-radius: 8px; padding: 9px 10px; display: grid; gap: 2px; }
.search__hit:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.search__board { font-size: 12px; color: var(--ink-mute); }
.search__text { overflow-wrap: anywhere; }
.search__none, .share__none { color: var(--ink-mute); padding: 10px 0; }
.share__lead { color: var(--ink-soft); font-size: 14px; margin: 0 0 12px; }
.share__form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 14px; }
.share__form input { grid-column: 1 / -1; }
.share__list li, .trash li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.share__who { flex: 1; display: grid; min-width: 0; }
.share__who small { color: var(--ink-mute); overflow: hidden; text-overflow: ellipsis; }
.share__h { margin: 22px 0 6px; font-size: 15px; }
.share__link { display: flex; gap: 8px; margin-bottom: 10px; }
.trash__type { font-size: 12px; font-weight: 700; min-width: 74px; }
.trash__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.trash small { color: var(--ink-mute); white-space: nowrap; }
.import { display: grid; gap: 12px; }
.import p { margin: 0; color: var(--ink-soft); }
.import__log { margin: 0; padding-left: 20px; font-size: 13px; color: var(--ink-soft); max-height: 240px; overflow: auto; }
.import__error { color: var(--accent); }
.shortcuts { border-collapse: collapse; width: 100%; }
.shortcuts td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.shortcuts td:first-child { white-space: nowrap; width: 1%; padding-right: 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-lift); font-size: 14px; max-width: calc(100% - 32px); }
.toast--error { background: var(--accent); color: #fff; }

/* ------------------------------------------------------------------ puhelin */
@media (max-width: 720px) {
  .topbar { padding: 0 6px 0 12px; }
  .status { display: none; }
  .crumbs__link { max-width: 90px; }
  .toolbar { top: auto; bottom: 10px; left: 10px; right: 70px; flex-direction: row; max-height: none; overflow-x: auto; overflow-y: hidden; }
  .toolbar hr { width: 1px; height: auto; border-top: 0; border-left: 1px solid var(--line); margin: 0 4px; }
  .tool { width: 56px; flex-shrink: 0; }
  .zoombar { flex-direction: column; bottom: 10px; right: 10px; }
  .zoombar__value { display: none; }
  .drawbar { top: 60px; left: 10px; right: 10px; transform: none; flex-wrap: wrap; justify-content: center; }
  .panel { top: 58px; right: 8px; left: 8px; width: auto; bottom: 8px; }
}

@media print {
  .topbar, .toolbar, .zoombar, .selbar, .formatbar, .drawbar { display: none !important; }
  .viewport { inset: 0; background: none; }
}

/* ==================================================================
   Milanoten ulkoasu (vaalea tila). Mitat luettu Milanoten omasta
   sivusta: leipäteksti 14/20 px, otsikot serif 17 px, kortin sisennys
   24/20/14/24, väriraita 5 px, taulukuvake 60 px pyöristys 16 px.
   ================================================================== */
:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: "Tiempos Text", Georgia, "Times New Roman", serif;
}
:root:not([data-theme="dark"]) {
  --paper: #ebecef;
  --dot: #cdd0d5;
  --ink: #323b4a;
  --ink-soft: #4f5866;
  --ink-mute: #8e95a1;
  --line: #e3e5e9;
  --shadow: 0 0 0 1px rgb(50 59 74 / 0.04), 0 1px 3px rgb(50 59 74 / 0.16);
  --radius: 3px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper: #1a1918; --dot: #33312d; --ink: #f1eee8; --ink-soft: #c9c5bc; --ink-mute: #8f8b82; --line: #3a3833; }
}
body { font-size: 14px; line-height: 20px; }

.crumbs__current { position: absolute; left: 50%; transform: translateX(-50%); max-width: 40vw; font-family: var(--serif); font-size: 20px; font-weight: 700; }
.crumbs__link { font-weight: 500; color: var(--ink); }

.card { color: var(--ink); }
.rich { padding: 24px 20px 14px 24px; font-size: 14px; line-height: 20px; }
.rich h1, .rich h2, .rich h3, .todo__title, .column__title, .doc-editor__title { font-family: var(--serif); }
.rich h1 { font-size: 24px; line-height: 30px; }
.rich h2 { font-size: 19px; line-height: 25px; }
.rich h3 { font-size: 17px; line-height: 22px; }
.rich ul, .rich ol { padding-left: 22px; }
.rich li { margin: 2px 0; }

/* Väriraita korttien ja sarakkeiden yläreunassa (Milanoten "color"). */
.card.has-accent::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--accent); border-radius: var(--radius) var(--radius) 0 0; z-index: 1; }
.card.has-accent > .rich, .card.has-accent > .todo__head { padding-top: 26px; }
.card.has-bg.on-dark { --ink: #ffffff; --ink-soft: #f1f1f1; --ink-mute: #d9d9d9; }

.todo__head { padding: 22px 20px 6px 24px; }
.todo__title { font-size: 17px; line-height: 22px; font-weight: 700; }
.todo__list { padding: 0 16px 14px 18px; }
.todo__item { padding: 4px 4px; font-size: 14px; line-height: 20px; }
.todo__check { border-radius: 3px; border-width: 1.5px; border-color: #9aa1ad; }
.todo__due { font-size: 12px; color: var(--ink-mute); white-space: nowrap; }

/* Sarake: valkoinen, keskitetty serif-otsikko ja korttimäärä, kortit reunuksella. */
.card--column, .card--column:not([class*=" c-"]) { background: var(--card); box-shadow: var(--shadow); }
.card--column.has-bg { background: var(--card); }
.column__head { flex-direction: column; gap: 0; padding: 22px 16px 14px; text-align: center; }
.column__title { font-size: 17px; line-height: 22px; font-weight: 700; width: 100%; text-align: center; }
.column__count { font-size: 13px; }
.column__body { gap: 10px; padding: 0 12px 12px; }
.card.in-column { box-shadow: none; border: 1px solid var(--line); }
.card.in-column.is-selected { box-shadow: 0 0 0 2px var(--select); }
.card--column.has-accent > .column__head { padding-top: 26px; }

/* Taulukuvake: 60 px neliö, kuva täyttää sen. */
.card--board { width: 100px; }
.boardcard__tile { width: 60px; height: 60px; border-radius: 16px; background: #5b607a; border: 0; overflow: hidden; }
.boardcard__tile.has-image { background: #fff; }
.boardcard__image { width: 100%; height: 100%; object-fit: cover; display: block; }
.boardcard__icon { font-size: 28px; }
.boardcard__icon:empty::before { width: 24px; height: 18px; border-width: 2px; }
.boardcard__title { font-size: 15px; font-weight: 600; line-height: 19px; margin-top: 8px; }
.boardcard__meta { font-size: 13px; line-height: 17px; }

/* Dokumentti: pieni sivu, nimi alla. */
.card--doc { background: transparent; box-shadow: none; padding: 0; text-align: center; cursor: pointer; }
.card--doc.is-selected { box-shadow: none; }
.card--doc.is-selected .doc__page { box-shadow: 0 0 0 2px var(--select), var(--shadow); }
.doc__page { width: 60px; height: 76px; margin: 0 auto; background: var(--card); border-radius: 3px; box-shadow: var(--shadow); padding: 8px 7px; overflow: hidden; text-align: left; }
.doc__lines { display: block; font-size: 4px; line-height: 6px; color: var(--ink-mute); word-break: break-all; }
.doc__title { font-family: var(--font); font-size: 15px; font-weight: 600; line-height: 19px; margin-top: 8px; }

.card--image .caption, .card--file .caption, .card--link .caption { padding: 8px 14px 10px; }
.link__meta { padding: 14px 20px 14px 24px; }
.comment__list { padding: 16px 16px 0; }

/* Tarkennukset Milanoten rinnalla verrattuna. */
.card--board, .card--doc { overflow: visible; }
.boardcard__title, .doc__title, .card--board .boardcard__meta, .card--doc .boardcard__meta { white-space: nowrap; width: max-content; min-width: 100%; max-width: 220px; margin-left: 50%; transform: translateX(-50%); overflow: hidden; text-overflow: ellipsis; }
.boardcard__title, .doc__title { font-size: 14px; line-height: 18px; margin-top: 10px; }
.boardcard__meta { font-size: 11px; line-height: 15px; }
.boardcard__letter { font-family: var(--serif); font-size: 26px; font-weight: 700; color: #fff; line-height: 1; }
.boardcard__tile[class*=" c-"] .boardcard__letter, .boardcard__tile.c-none .boardcard__letter { color: var(--ink); }
.doc__page { position: relative; width: 48px; height: 58px; padding: 0; margin-top: 2px; display: grid; align-content: center; justify-items: start; gap: 4px; padding-left: 9px; border-radius: 2px; box-shadow: 0 0 0 1px rgb(50 59 74 / 0.08), 0 1px 3px rgb(50 59 74 / 0.18); }
.doc__page::after { content: ""; position: absolute; right: 0; top: 0; width: 11px; height: 11px; background: linear-gradient(225deg, var(--paper) 50%, #dfe2e6 50%); }
.doc__glyph { font-family: var(--serif); font-weight: 700; font-size: 15px; line-height: 1; color: var(--ink); }
.doc__rule { display: block; width: 26px; height: 2px; background: var(--ink); border-radius: 1px; }
.doc__rule--short { width: 16px; }
.card--image.is-transparent { background: transparent; box-shadow: none; }
.card--image.is-transparent .image__img { background: transparent; }
.card--image.is-transparent.is-selected { box-shadow: 0 0 0 2px var(--select); }
.rich li { margin: 5px 0; }
.rich ul, .rich ol { margin: 6px 0; }
.boardcard__tile.is-light .boardcard__letter { color: rgb(50 59 74 / 0.75); }
.card.has-bg.on-light { --ink: #323b4a; --ink-soft: #4f5866; --ink-mute: #6f7785; }
.column__head { position: relative; }
.column__toggle { position: absolute; top: 12px; right: 10px; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-mute); font-size: 15px; line-height: 1; opacity: 0; }
.card--column:hover .column__toggle, .card--column.is-collapsed .column__toggle { opacity: 1; }
.column__toggle:hover { background: rgb(50 59 74 / 0.08); color: var(--ink); }
.card--column.is-collapsed .column__body { display: none; }
.card--column.is-collapsed .column__head { padding-bottom: 18px; }
.import__picker { display: grid; gap: 6px; }
.import__choice { display: flex; align-items: center; gap: 8px; font-weight: 500; }

/* Hennot taustapisteet: kiinteä 1 px koko zoomauksesta riippumatta. */
.viewport { background-image: radial-gradient(circle, rgb(50 59 74 / 0.16) 1px, transparent 1.2px); }
.image__empty { height: 200px; display: grid; place-items: center; background: #f3f4f6; color: var(--ink-mute); font-size: 13px; }

/* Taulu sarakkeen sisällä: matala rivi, kuvake vasemmalla (kuten Milanotessa). */
.card--board.in-column { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 10px 12px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card--board.in-column .boardcard__tile { grid-row: 1 / 3; width: 40px; height: 40px; border-radius: 10px; margin: 0; }
.card--board.in-column .boardcard__letter { font-size: 18px; }
.card--board.in-column .boardcard__icon { font-size: 20px; }
.card--board.in-column .boardcard__title, .card--board.in-column .boardcard__meta { margin: 0; transform: none; width: auto; min-width: 0; max-width: none; align-self: end; }
.card--board.in-column .boardcard__meta { align-self: start; }
.card--board.in-column:hover .boardcard__tile { transform: none; }
.card--board.in-column.is-selected { box-shadow: 0 0 0 2px var(--select); }
.card--board.in-column.is-selected .boardcard__tile { box-shadow: none; }
.card--doc.in-column { display: grid; grid-template-columns: 40px 1fr; column-gap: 12px; align-items: center; padding: 10px 12px; text-align: left; background: var(--card); border: 1px solid var(--line); }
.card--doc.in-column .doc__page { grid-row: 1 / 3; width: 34px; height: 42px; margin: 0; gap: 3px; padding-left: 6px; }
.card--doc.in-column .doc__glyph { font-size: 11px; }
.card--doc.in-column .doc__rule { width: 18px; }
.card--doc.in-column .doc__rule--short { width: 11px; }
.card--doc.in-column .doc__title, .card--doc.in-column .boardcard__meta { margin: 0; transform: none; width: auto; min-width: 0; max-width: none; }
.card--doc.in-column .doc__title { align-self: end; }
.card--doc.in-column .boardcard__meta { align-self: start; }

/* Oikean painikkeen valikko. */
.ctxmenu { position: fixed; z-index: 95; min-width: 210px; padding: 6px; background: var(--card); border-radius: 10px; box-shadow: 0 0 0 1px rgb(50 59 74 / 0.06), 0 10px 30px rgb(50 59 74 / 0.22); display: grid; font-size: 14px; }
.ctxmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.ctxmenu__item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 6px; color: var(--ink); cursor: pointer; list-style: none; }
.ctxmenu__item::-webkit-details-marker { display: none; }
.ctxmenu__item:hover { background: rgb(50 59 74 / 0.07); }
.ctxmenu__item--danger { color: var(--accent); }
.ctxmenu__sub > summary::after { content: "›"; float: right; color: var(--ink-mute); }
.ctxmenu__sub[open] > summary::after { content: "⌄"; }
.ctxmenu__panel { padding: 4px 4px 6px; }
.ctxmenu__icons { display: grid; grid-template-columns: repeat(8, 30px); gap: 2px; margin-bottom: 4px; }
.ctxmenu__icons .selbar__icon { width: 30px; height: 30px; font-size: 17px; }
.ctxmenu__colors { display: grid; grid-template-columns: repeat(8, 24px); gap: 6px; padding: 4px; }
.ctxmenu__colors .selbar__swatch { width: 24px; height: 24px; }
.is-renaming { outline: 2px solid var(--select); outline-offset: 2px; border-radius: 3px; background: var(--card); user-select: text; -webkit-user-select: text; cursor: text; }

/* Maininnat ja ilmoitukset */
[data-mention] { color: #2f6fdf; background: rgb(47 111 223 / 0.1); border-radius: 4px; padding: 0 3px; font-weight: 500; }
.mentions { position: fixed; z-index: 96; min-width: 240px; padding: 5px; background: var(--card); border-radius: 10px; box-shadow: 0 0 0 1px rgb(50 59 74 / 0.06), 0 10px 30px rgb(50 59 74 / 0.22); display: grid; }
.mentions__item { display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: transparent; padding: 7px 9px; border-radius: 7px; }
.mentions__item span:last-child { display: grid; line-height: 1.25; }
.mentions__item small { color: var(--ink-mute); font-size: 12px; }
.mentions__item.is-active, .mentions__item:hover { background: rgb(50 59 74 / 0.07); }
.bell { position: relative; }
.bell__badge { position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
.notes { display: grid; gap: 10px; justify-items: start; }
.notes__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; width: 100%; }
.notes__item { width: 100%; display: grid; gap: 3px; text-align: left; border: 0; background: transparent; padding: 10px; border-radius: 8px; }
.notes__item:hover { background: rgb(50 59 74 / 0.06); }
.is-unread .notes__item { background: rgb(196 32 50 / 0.06); }
.notes__who { font-size: 14px; }
.notes__text { font-size: 13px; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notes__item small { color: var(--ink-mute); }
.mentions--hint { max-width: 270px; padding: 10px 12px; font-size: 13px; color: var(--ink-soft); } .mentions--hint p { margin: 0; }

/* Kalenteri */
.card--calendar { padding: 18px 18px 14px; }
.cal__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.cal__title { font-family: var(--serif); font-size: 17px; font-weight: 700; min-width: 80px; }
.cal__nav { display: flex; align-items: center; gap: 2px; }
.cal__nav button { border: 0; background: transparent; border-radius: 6px; padding: 4px 8px; color: var(--ink); font-size: 14px; }
.cal__nav button:hover { background: rgb(50 59 74 / 0.07); }
.cal__month { font-weight: 600; min-width: 128px; }
.cal__add { margin-left: 6px; border: 1px solid var(--line) !important; font-size: 13px !important; }
.cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal__dow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-mute); padding: 6px 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal__day { min-height: 74px; padding: 4px 4px 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; }
.cal__day:hover { background: rgb(50 59 74 / 0.03); }
.cal__day.is-other { background: rgb(50 59 74 / 0.025); }
.cal__day.is-other .cal__num { color: var(--ink-mute); }
.cal__num { font-size: 12px; font-weight: 600; align-self: flex-end; padding: 1px 5px; border-radius: 10px; }
.cal__day.is-today .cal__num { background: var(--accent); color: #fff; }
.cal__event { display: block; width: 100%; text-align: left; border: 0; border-radius: 4px; padding: 2px 5px; font-size: 11.5px; line-height: 15px; background: rgb(47 111 223 / 0.12); color: #1f4fa8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal__event.is-allday { background: #2f6fdf; color: #fff; }
.cal__event.is-task { background: rgb(50 59 74 / 0.07); color: var(--ink-soft); }
.cal__event.is-task.is-done { text-decoration: line-through; opacity: .6; }
.cal__bell { font-size: 9px; margin-left: 3px; }
.cal__more { font-size: 11px; color: var(--ink-mute); padding-left: 5px; }
.cal__upcoming { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.cal__label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-mute); margin-right: 4px; }
.cal__next { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--ink); }

/* Tapahtuman muokkaus */
.ev { display: grid; gap: 12px; }
.ev input[type=text], .ev input[type=date], .ev input[type=time], .ev select, .ev textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--paper); font: inherit; color: var(--ink); }
.ev__title { font-size: 18px !important; font-weight: 600; }
.ev__row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.ev__row label, .ev__check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.ev__field { display: grid; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.ev__people { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--ink); font-size: 14px; }
.ev__notes { resize: vertical; }
.ev__actions { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.feed { display: grid; gap: 12px; font-size: 14px; }
.feed p { margin: 0; }
.feed__steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.feed__warn { color: var(--accent); font-size: 13px; }
.feed__note { color: var(--ink-mute); font-size: 13px; }

/* Takaisin-nappi */
.topbar__left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.backbtn { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px 5px 8px; font-size: 13px; font-weight: 500; color: var(--ink); }
.backbtn:hover { border-color: var(--ink-mute); }
.backbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 720px) { .backbtn span { display: none; } .backbtn { padding: 5px 7px; } }

/* Puhelin: yläpalkki ja kosketus */
.viewport, .card { -webkit-touch-callout: none; }
@media (max-width: 720px) {
  .topbar { gap: 6px; }
  .topbar__left { flex: 1; min-width: 0; }
  .crumbs__link, .crumbs__sep { display: none; }
  .crumbs__current { position: static; transform: none; max-width: 100%; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .crumbs__shared { margin-left: 4px; padding: 3px 8px; font-size: 12px; white-space: nowrap; }
  .topbar__right { gap: 0; }
  .topbar__right .iconbtn { width: 32px; }
  #btn-share { padding: 4px 10px; }
  .presence { display: none; }
  .selbar { max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none; }
  .ctxmenu { max-width: calc(100vw - 16px); }
  .modal { padding: 8px; align-items: end; }
  .modal__box { max-height: calc(100dvh - 16px); }
  .ev__row { gap: 10px; }
}

/* Tehtävän deadline ja poisto */
.todo__item { align-items: center; }
.todo__due { flex-shrink: 0; display: inline-flex; align-items: center; gap: 3px; border: 0; background: transparent; border-radius: 5px; padding: 1px 5px; font-size: 12px; color: var(--ink-mute); white-space: nowrap; cursor: pointer; }
.todo__due svg, .todo__del svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.todo__due:not(.has-due) { opacity: 0; }
.todo__item:hover .todo__due, .card.is-selected .todo__due, .card.is-editing .todo__due, .todo__due:focus-visible { opacity: 1; }
@media (hover: none) { .todo__due:not(.has-due) { opacity: 0.45; } }
.todo__due.has-due { background: rgb(50 59 74 / 0.06); color: var(--ink-soft); }
.todo__due.is-today { background: rgb(255 154 61 / 0.18); color: #b4570b; }
.todo__due.is-late { background: rgb(196 32 50 / 0.12); color: var(--accent); font-weight: 600; }
.todo__due:hover { background: rgb(50 59 74 / 0.1); color: var(--ink); }
.todo__due:disabled { cursor: default; }
.todo__item.is-done .todo__due.has-due { text-decoration: line-through; opacity: .7; }
.todo__del { flex-shrink: 0; display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; background: transparent; border-radius: 5px; color: var(--ink-mute); cursor: pointer; }
.todo__del:hover { background: rgb(196 32 50 / 0.1); color: var(--accent); }
.todo__datepicker { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.todo__item { position: relative; }

/* Siirtokahva: vain kosketusnäytöillä ja valitussa kortissa. */
.card__grip { display: none; }
@media (hover: none) and (pointer: coarse) {
  .card.is-selected:not(.is-editing) > .card__grip { display: grid; place-items: center; position: absolute; top: -18px; left: -18px; width: 36px; height: 36px; border-radius: 50%; background: var(--select); color: #fff; box-shadow: 0 2px 8px rgb(0 0 0 / 0.25); z-index: 5; touch-action: none; }
  .card__grip svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .card__resize { opacity: 1; width: 28px; height: 28px; right: -10px; bottom: -10px; }
}
@media (max-width: 720px), (hover: none) {
  .tool { touch-action: pan-x; }
  .toolbar { touch-action: pan-x; -webkit-overflow-scrolling: touch; }
}

/* iPhone: kotipalkki, lovi ja selaimen palkit. Sovellus käyttää näkyvää
   korkeutta (dvh), ja reunoilla olevat palkit pysyvät turva-alueen sisällä. */
html, body { height: 100dvh; }
.app { height: 100dvh; inset: 0 0 auto 0; }
.topbar { padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); }
.viewport { top: calc(52px + env(safe-area-inset-top)); }
.zoombar { bottom: calc(12px + env(safe-area-inset-bottom)); right: calc(12px + env(safe-area-inset-right)); }
.toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
@media (max-width: 720px) {
  .toolbar { bottom: calc(10px + env(safe-area-inset-bottom)); left: calc(10px + env(safe-area-inset-left)); }
  .zoombar { bottom: calc(10px + env(safe-area-inset-bottom)); }
  .panel { bottom: calc(8px + env(safe-area-inset-bottom)); top: calc(58px + env(safe-area-inset-top)); }
  .modal { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}
