/* ねたはこ Web版 — iOS版(ContentView_iOS.swift の NetaPalette など)の値に合わせたスタイル */

:root {
  /* ---- NetaPalette (ライト) ---- */
  --text: #000000;
  --bg: color(srgb 0.94 0.92 0.88);
  --card: #ffffff;
  --copied: color(srgb 0.88 0.85 0.78);
  --fold: color(srgb 0.86 0.86 0.84);
  --border: rgba(0, 0, 0, 0.25);
  --tab: #fcb315;
  --tab1: color(srgb 0.30 0.69 0.48);
  --tab2: color(srgb 0.25 0.50 0.82);
  --tab3: color(srgb 0.54 0.39 0.79);
  --tab4: color(srgb 0.88 0.48 0.65);
  --botsu: #cc1236;
  --board-header: rgba(0, 0, 0, 0.06);
  /* ---- iOS システムカラー ---- */
  --gray: #8e8e93;
  --secondary: rgba(60, 60, 67, 0.6);
  --blue: #007aff;
  --red: #ff3b30;
  --green: #34c759;
  --sep: rgba(60, 60, 67, 0.29);
  --grouped-bg: #f2f2f7;
  --grouped-cell: #ffffff;
  --seg-bg: rgba(118, 118, 128, 0.12);
  --seg-sel: #ffffff;
  --alert-bg: rgba(242, 242, 242, 0.86);
  --alert-sep: rgba(60, 60, 67, 0.3);
  --dim: rgba(0, 0, 0, 0.4);
  --sheet-shadow: 0 -2px 30px rgba(0, 0, 0, 0.18);
  --user-font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --text: #e0d6cb;
  --bg: color(srgb 0.1 0.1 0.1);
  --card: #1c1b17;
  --copied: #34312a;
  --fold: color(srgb 0.30 0.30 0.30);
  --border: rgba(255, 255, 255, 0.25);
  --tab: #a5c8d1;
  --tab1: color(srgb 0.56 0.82 0.66);
  --tab2: color(srgb 0.56 0.71 0.92);
  --tab3: color(srgb 0.73 0.64 0.90);
  --tab4: color(srgb 0.92 0.66 0.78);
  --board-header: rgba(255, 255, 255, 0.08);
  --secondary: rgba(235, 235, 245, 0.6);
  --blue: #0a84ff;
  --red: #ff453a;
  --green: #30d158;
  --sep: rgba(84, 84, 88, 0.6);
  --grouped-bg: #000000;
  --grouped-cell: #1c1c1e;
  --seg-bg: rgba(118, 118, 128, 0.24);
  --seg-sel: #636366;
  --alert-bg: rgba(44, 44, 46, 0.86);
  --alert-sep: rgba(84, 84, 88, 0.6);
  --dim: rgba(0, 0, 0, 0.55);
  --sheet-shadow: 0 -2px 30px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

body.font-mincho {
  --user-font: "Hiragino Mincho ProN", "Hiragino Mincho Pro", "BIZ UDMincho", "Yu Mincho", YuMincho, "Noto Serif JP", "Noto Serif CJK JP", serif;
}
body.font-mincho .uf { font-weight: 600; }
:root { --bl: 17px; --cl: 20px; }
body.font-mincho { --bl: 20px; --cl: 23px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  font-size: 17px;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: 0.35; cursor: default; }
textarea, input { font: inherit; color: inherit; }
.uf { font-family: var(--user-font); }
.gray { color: var(--gray); }
.secondary { color: var(--secondary); }
.noselect { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
svg.ic { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.125em; }

#root { position: fixed; inset: 0; }

/* ---------- 画面の骨組み ---------- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); min-width: 0; }
.screen.push-in { animation: pushIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes pushIn { from { transform: translateX(100%); } to { transform: none; } }

.navbar {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: calc(44px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  background: var(--bg); position: relative; z-index: 2;
}
@media (min-width: 700px) { .split .navbar { min-height: calc(56px + env(safe-area-inset-top)); padding-top: max(env(safe-area-inset-top), 8px); } }
.navbar .nb-lead { justify-self: start; display: flex; align-items: center; gap: 4px; min-width: 0; }
.navbar .nb-trail { justify-self: end; display: flex; align-items: center; gap: 4px; }
.nb-title { font-size: 17px; font-weight: 600; max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 8px 4px; }
.nbtn { color: var(--blue); min-width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; font-size: 17px; white-space: nowrap; }
.nbtn svg.ic { font-size: 22px; }
.nbtn.back { justify-content: flex-start; padding-left: 4px; }
.nbtn.back svg.ic { font-size: 24px; stroke-width: 2.2; }
.nbtn.bold { font-weight: 600; }

.large-title { font-size: 34px; font-weight: 700; margin: 4px 0 6px; padding: 0 12px 0 20px; line-height: 1.2; letter-spacing: 0.2px; }

.scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* ---------- 文字ボタン / 丸ボタン(NetaTextButton など) ---------- */
.textbtn {
  padding: 8px 16px; border-radius: 4px; background: var(--bg); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border); white-space: nowrap; line-height: 1.25;
}
.squarebtn {
  width: 44px; height: 36px; border-radius: 4px; background: var(--bg); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
}
.circlebtn {
  border-radius: 50%; background: var(--card); color: var(--text); box-shadow: inset 0 0 0 1px var(--border);
  display: inline-flex; align-items: center; justify-content: center;
}
.bottom-bar { flex: none; position: relative; padding: 0 0 calc(8px + env(safe-area-inset-bottom)); display: flex; justify-content: center; align-items: center; min-height: 60px; }
.bottom-bar .left { position: absolute; left: calc(16px + env(safe-area-inset-left)); top: 50%; transform: translateY(-50%); }
.sidebar-bar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); background: var(--bg); }

/* ---------- ネタ帳の行 ---------- */
.pcol { padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
.pgroup { display: flex; flex-direction: column; gap: 8px; }
.pgap { height: 48px; flex: none; }
.pcol .pgroup + .pgap { margin-top: 8px; }
.pcol .pgap + .swipe { margin-top: 8px; }
.prow {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 14px 12px 14px 20px;
  background: var(--card); border-radius: 4px; cursor: pointer;
}
.prow::after { content: ""; position: absolute; inset: -0.5px; border: 1px solid var(--border); border-radius: 4.5px; pointer-events: none; }
.prow.selected::after { border-color: color-mix(in srgb, var(--text) 90%, transparent); }
.prow .tabbar { position: absolute; left: 0; top: 0; bottom: 0; width: 7px; border-radius: 4px 0 0 4px; background: var(--tab); }
.prow .name { flex: 1; min-width: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .count { font-size: 13px; color: var(--gray); }

/* ---------- スワイプ行 ---------- */
.swipe { position: relative; }
.swipe .sw-content { position: relative; touch-action: pan-y; }
.swipe.moving .sw-content { transition: none; }
.swipe .sw-content.snap { transition: transform 0.2s ease-out; }
.swipe .sw-trail { position: absolute; top: 0; right: 0; bottom: 0; display: flex; overflow: hidden; border-radius: 4px; width: 0; }
.swipe .sw-trail button { flex: 1; min-width: 80px; background: var(--red); color: #fff; font-size: 14px; font-weight: 500; }
.swipe .sw-lead { position: absolute; top: 0; left: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding-left: 12px; overflow: hidden; width: 0; }
.chip { flex: none; width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 20%, transparent); }
.chip.on { box-shadow: inset 0 0 0 2.5px color-mix(in srgb, var(--text) 90%, transparent); }
.reorder-active { z-index: 5 !important; transform-origin: center; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25); }

/* ---------- カードの下地(cardSurface) ---------- */
.cs { position: relative; }
.cs-bg { position: absolute; inset: 0; background: var(--fill, var(--card)); border-radius: 4px; }
.cs::after { content: ""; position: absolute; inset: -0.5px; border: 1px solid var(--edge, var(--border)); border-radius: 4.5px; pointer-events: none; }
.cs.dogear .cs-bg { border-radius: 0; }
.cs.dogear::after { display: none; }
svg.cs-edge { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
svg.cs-edge line { stroke: var(--edge, var(--border)); stroke-width: 1; stroke-linecap: square; }
svg.cs-flap { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
svg.cs-flap polygon { fill: var(--fold); stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-linejoin: miter; }
.cs-unfold { position: absolute; left: -3px; top: -3px; z-index: 3; }
.cs-in { position: relative; z-index: 1; border-radius: 4px; overflow: hidden; }

/* ---------- カード一覧 ---------- */
.cards-wrap { padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); max-width: 1000px; margin: 0 auto; }
.cards-stack { display: flex; flex-direction: column; gap: 12px; }
.cards-col { display: flex; flex-direction: column; gap: 12px; }
.cards-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.empty-note { text-align: center; padding-top: 40px; color: var(--secondary); }
.newcard-in { padding: 12px; min-height: 70px; font-size: 15px; color: var(--gray); }
.card-in { padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.card.copied .card-in { padding-top: 18px; }
.card-text { font-size: 15px; line-height: var(--cl); white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; text-align: left; }
.card-meta { display: flex; align-items: center; justify-content: space-between; }
.card-meta .date { font-size: 12px; color: var(--gray); }
.copybtn { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 8px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--border); color: var(--text); }
.editor-in { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.editor-in textarea { width: 100%; border: 0; outline: 0; background: transparent; resize: none; font-size: 15px; line-height: var(--cl); color: var(--text); padding: 0; min-height: calc(var(--cl) * 3); display: block; overflow-y: auto; }
.editor-in .row { display: flex; justify-content: flex-end; }
.prominent { background: var(--tab); color: rgba(0, 0, 0, 0.85); font-size: 14px; padding: 7px 14px; border-radius: 999px; min-height: 32px; }

/* ---------- ボード ---------- */
.board { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--bg); touch-action: none; }
.board-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--gray); pointer-events: none; text-align: center; padding: 20px; }
.bcard { position: absolute; left: 0; top: 0; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.25)); touch-action: none; cursor: grab; will-change: transform; }
.bcard.tidy { transition: transform 0.25s ease-in-out; }
.bcard.dragging { filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25)); z-index: 5; cursor: grabbing; }
.bcard.editing { z-index: 5; cursor: text; }
.bcard .bhead { height: 26px; display: flex; align-items: center; justify-content: space-between; background: var(--board-header); }
.bcard .bhead .date { font-size: 11px; color: var(--gray); padding-left: 8px; }
.bcard .bhead .x { width: 40px; height: 26px; font-size: 17px; font-weight: 600; color: var(--gray); }
.bcard .bbody { padding: 6px; }
.bcard .btext { font-size: 14px; line-height: var(--bl); padding: 0 5px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; text-align: left; }
.bcard textarea { display: block; width: 100%; height: 100%; border: 0; outline: 0; background: transparent; resize: none; font-size: 14px; line-height: var(--bl); padding: 0 5px; color: var(--text); overflow: hidden; }
.bcard .bcopy { position: absolute; right: 0; bottom: 0; padding: 10px; font-size: 13px; color: var(--gray); line-height: 1; z-index: 2; }
#measure { position: absolute; visibility: hidden; left: -9999px; top: 0; font-size: 14px; line-height: var(--bl); white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; padding: 0; }

/* ---------- iPad / デスクトップの分割表示 ---------- */
.split { position: absolute; inset: 0; display: flex; background: var(--bg); }
.sidebar { width: 320px; flex: none; display: flex; flex-direction: column; background: var(--bg); border-right: 0.5px solid var(--sep); min-height: 0; }
.sidebar .navbar .nb-title { display: none; }
.detail { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.detail-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--secondary); }
.split.board-mode .sidebar { display: none; }
.drawer-dim { position: absolute; inset: 0; background: var(--dim); z-index: 20; }
.drawer { position: absolute; left: 0; top: 0; bottom: 0; width: 320px; max-width: 86vw; z-index: 21; display: flex; flex-direction: column; background: var(--bg); box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25); animation: drawerIn 0.25s ease-out; }
@keyframes drawerIn { from { transform: translateX(-100%); } to { transform: none; } }

/* ---------- シート ---------- */
.dim { position: fixed; inset: 0; background: var(--dim); z-index: 50; animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: fixed; z-index: 51; left: 0; right: 0; bottom: 0; background: var(--bg); color: var(--text);
  border-radius: 28px 28px 0 0; box-shadow: var(--sheet-shadow); display: flex; flex-direction: column; overflow: hidden;
  animation: sheetUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); padding-bottom: env(safe-area-inset-bottom);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet.rename { height: 190px; }
.sheet.search { height: min(80%, 620px); }
.sheet.settings { top: 12px; background: var(--grouped-bg); color: #000; }
:root[data-theme="dark"] .sheet.settings { color: #fff; }
.sheet .navbar { min-height: 56px; padding-top: 6px; background: transparent; }
.sheet.settings .navbar { background: var(--grouped-bg); }
.sheet .sheet-body { flex: 1; min-height: 0; overflow-y: auto; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; width: 540px; bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: 20px; animation: fade 0.2s; padding-bottom: 0; }
  .sheet.rename { height: 190px; }
  .sheet.search { height: min(70%, 560px); }
  .sheet.settings { top: 50%; height: min(86%, 760px); }
}
.fieldbox { display: flex; align-items: center; gap: 8px; margin: 12px 16px 8px; padding: 12px; background: var(--card); border-radius: 8px; box-shadow: inset 0 0 0 1px var(--border); }
.fieldbox input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 17px; color: var(--text); }
.fieldbox .clear { color: var(--gray); font-size: 20px; line-height: 1; display: flex; }
.fieldbox .clear svg { width: 20px; height: 20px; }
.results { list-style: none; margin: 0; padding: 0; }
.results li { padding: 11px 16px; border-bottom: 0.5px solid var(--sep); cursor: pointer; }
.results .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 17px; }
.results .p { font-size: 12px; color: var(--secondary); margin-top: 4px; }
.center-note { text-align: center; color: var(--secondary); padding-top: 32px; }

/* 設定(Form) */
.form { padding: 4px 16px 40px; }
.fsec { margin-top: 24px; }
.fsec > h3 { margin: 0 0 7px 16px; font-size: 13px; font-weight: 400; color: var(--secondary); text-transform: none; }
.fcell { background: var(--grouped-cell); border-radius: 12px; padding: 11px 16px; }
.fcell + .fcell { margin-top: 1px; border-radius: 12px; }
.fnote { font-size: 12px; color: var(--secondary); margin: 6px 16px 0; line-height: 1.4; }
.seg { display: flex; background: var(--seg-bg); border-radius: 9px; padding: 2px; gap: 0; }
.seg button { flex: 1; padding: 6px 4px; font-size: 14px; border-radius: 7px; text-align: center; white-space: nowrap; }
.seg button.on { background: var(--seg-sel); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 3px 8px rgba(0, 0, 0, 0.06); }
.toggle-row { display: flex; align-items: center; gap: 12px; }
.toggle-row .lbl { flex: 1; }
.toggle-row .lbl small { display: block; font-size: 12px; color: var(--secondary); margin-top: 2px; }
.switch { position: relative; width: 51px; height: 31px; border-radius: 999px; background: rgba(120, 120, 128, 0.32); flex: none; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.5; }
.smallbtns { display: flex; gap: 10px; }
.bordered { font-size: 14px; color: var(--blue); background: color-mix(in srgb, var(--blue) 15%, transparent); padding: 6px 14px; border-radius: 999px; }
.fcell .kv { display: flex; justify-content: space-between; }
.fcell .kv span:last-child { color: var(--secondary); }

/* アラート */
.alert-dim { position: fixed; inset: 0; z-index: 70; background: var(--dim); display: flex; align-items: center; justify-content: center; animation: fade 0.15s; padding: 20px; }
.alert { width: 270px; max-width: 100%; border-radius: 14px; background: var(--alert-bg); -webkit-backdrop-filter: blur(30px) saturate(1.8); backdrop-filter: blur(30px) saturate(1.8); text-align: center; overflow: hidden; color: var(--text); }
:root:not([data-theme="dark"]) .alert { color: #000; }
:root[data-theme="dark"] .alert { color: #fff; }
.alert .body { padding: 18px 16px 16px; }
.alert h4 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; }
.alert p { margin: 4px 0 0; font-size: 13px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.alert .btns { display: flex; border-top: 0.5px solid var(--alert-sep); }
.alert .btns.stack { flex-direction: column; }
.alert .btns button { flex: 1; padding: 11px 8px; font-size: 17px; color: var(--blue); }
.alert .btns button + button { border-left: 0.5px solid var(--alert-sep); }
.alert .btns button.cancel { font-weight: 600; }
.alert .btns button.destructive { color: var(--red); }

/* App Storeリンク・言語選択 */
.store-link { display: flex; align-items: center; gap: 12px; margin: 14px 12px 18px; padding: 12px 14px; background: var(--card); border-radius: 12px; color: var(--blue); text-decoration: none; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.08); }
.store-link.plain { margin: 0; padding: 0; background: none; box-shadow: none; }
.store-link .ic { width: 24px; height: 24px; flex: none; }
.store-link span { display: flex; flex-direction: column; min-width: 0; }
.store-link b { font-weight: 600; font-size: 16px; }
.store-link small { font-size: 12px; color: var(--secondary); }
.langsel { width: 100%; font: inherit; font-size: 16px; padding: 4px 0; border: 0; background: transparent; color: var(--text); -webkit-appearance: menulist; appearance: menulist; }

.store-banner { flex: none; display: block; margin: 0 12px 4px; border-radius: 12px; overflow: hidden; background: var(--card); text-decoration: none; color: var(--blue); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.12); }
.store-banner img { display: block; width: 100%; height: auto; }
.store-banner .cap { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 8px 12px 9px; }
.store-banner b { font-weight: 600; font-size: 14px; }
.store-banner small { font-size: 11px; color: var(--secondary); white-space: nowrap; }
