/* Carnet Japon: papier washi, encre sumi, vermillon torii */
:root {
    --paper: #f4efe6;
    --paper-2: #ebe3d4;
    --card: #fbf8f2;
    --ink: #1c1a17;
    --ink-2: #57504a;
    --ink-3: #8b8279;
    --line: #d9cfbf;
    --red: #c8372d;
    --red-soft: #f3d9d3;
    --indigo: #2b3a55;
    --moss: #5d6b3f;
    --gold: #b48a3c;
    --shadow: 0 1px 0 rgba(28, 26, 23, .04), 0 10px 30px -18px rgba(28, 26, 23, .35);
    --radius: 14px;
    --display: "Shippori Mincho", "Hiragino Mincho ProN", serif;
    --body: "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #16140f;
        --paper-2: #1f1c16;
        --card: #211e18;
        --ink: #efe8db;
        --ink-2: #c1b7a8;
        --ink-3: #8a8174;
        --line: #36312a;
        --red: #e5574b;
        --red-soft: #3a1f1b;
        --indigo: #9fb1d6;
        --moss: #a9b889;
        --gold: #d8b36a;
        --shadow: 0 10px 30px -18px rgba(0, 0, 0, .8);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 15px/1.6 var(--body);
    min-height: 100vh;
    overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--red); }
img, video { max-width: 100%; display: block; }

.grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: .5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .35 0 0 0 0 .3 0 0 0 .08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- En-tête ---------- */
.top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px 24px;
    align-items: center;
    padding: 14px max(16px, env(safe-area-inset-left)) 12px;
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-kanji {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--red);
    color: #fff8ef;
    font: 800 26px/1 var(--display);
    transform: rotate(-6deg);
    box-shadow: inset 0 0 0 3px color-mix(in srgb, #fff 18%, transparent);
}
.brand h1 { margin: 0; font: 800 22px/1.1 var(--display); letter-spacing: .02em; }
.brand-sub { margin: 2px 0 0; color: var(--ink-3); font-size: 12.5px; }

.search {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 620px;
    width: 100%;
    justify-self: center;
}
.search svg {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--ink-3);
    stroke-width: 2;
    stroke-linecap: round;
}
.search input {
    width: 100%;
    padding: 12px 44px 12px 42px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    -webkit-appearance: none;
}
.search input:focus { border-color: var(--ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 14%, transparent); }
.search kbd {
    position: absolute;
    right: 14px;
    padding: 1px 7px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: 12px var(--body);
    color: var(--ink-3);
}

.views { display: flex; gap: 4px; padding: 4px; background: var(--paper-2); border-radius: 999px; }
.view-btn {
    border: 0;
    background: none;
    padding: 7px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 500;
    color: var(--ink-2);
    white-space: nowrap;
}
.view-btn.is-active { background: var(--ink); color: var(--paper); }

/* ---------- Filtres ---------- */
.filters { position: relative; z-index: 1; padding: 14px 16px 0; max-width: 1400px; margin: 0 auto; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    cursor: pointer;
    font-size: 13.5px;
    transition: all .15s;
}
.chip b { font-weight: 500; color: var(--ink-3); font-size: 12px; }
.chip:hover { border-color: var(--ink-2); }
.chip.is-on { background: var(--red); border-color: var(--red); color: #fff8ef; }
.chip.is-on b { color: #fff8ef; opacity: .8; }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.filter-row select {
    padding: 7px 30px 7px 12px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b8279'/%3E%3C/svg%3E") no-repeat right 11px center;
    -webkit-appearance: none;
    appearance: none;
    font-size: 13.5px;
}
.link-btn { border: 0; background: none; color: var(--ink-3); text-decoration: underline; cursor: pointer; font-size: 13px; }
.result-line { margin: 10px 0 0; color: var(--ink-3); font-size: 13px; }
.result-line strong { color: var(--ink); }

/* ---------- Vues ---------- */
main { position: relative; z-index: 1; max-width: 1400px; margin: 0 auto; padding: 14px 16px 80px; }
.view { display: none; }
.view.is-active { display: block; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    border: 1px solid var(--line);
    transition: transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s;
    animation: rise .5s both cubic-bezier(.2, .8, .2, 1);
    animation-delay: calc(var(--i, 0) * 25ms);
    text-align: left;
    padding: 0;
}
.card:hover { transform: translateY(-3px) rotate(-.3deg); }
.card:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.card-thumb { position: relative; aspect-ratio: 4 / 5; background: var(--paper-2); overflow: hidden; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s; }
.card:hover .card-thumb img { transform: scale(1.04); }
.card-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 55%, rgba(0, 0, 0, .55)); }
.card-kind {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(20, 18, 15, .6);
    color: #fff;
    font-size: 11.5px;
    backdrop-filter: blur(6px);
}
.card-status { position: absolute; top: 10px; right: 10px; z-index: 1; display: flex; gap: 4px; }
.card-status span {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--card);
    font-size: 13px;
}
.card-city {
    position: absolute;
    left: 12px;
    bottom: 10px;
    z-index: 1;
    color: #fff;
    font: 700 17px/1.2 var(--display);
    text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
}
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { margin: 0; font: 700 16px/1.3 var(--display); }
.card-meta { color: var(--ink-3); font-size: 12.5px; }
.card-hit {
    margin: 2px 0 0;
    padding: 6px 8px;
    border-left: 3px solid var(--red);
    background: var(--red-soft);
    border-radius: 0 6px 6px 0;
    font-size: 12.5px;
    color: var(--ink-2);
}
mark { background: color-mix(in srgb, var(--gold) 40%, transparent); color: inherit; padding: 0 1px; border-radius: 2px; }

.stamps { display: flex; flex-wrap: wrap; gap: 5px; }
.stamp {
    display: inline-block;
    padding: 1px 7px;
    border: 1.5px solid currentColor;
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--red);
    transform: rotate(-1.5deg);
}
.stamp:nth-child(2n) { color: var(--indigo); transform: rotate(1deg); }
.stamp:nth-child(3n) { color: var(--moss); }

/* ---------- Carte ---------- */
#map { height: calc(100vh - 260px); min-height: 420px; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.leaflet-popup-content-wrapper { border-radius: 12px; font-family: var(--body); }
.map-pop h4 { margin: 0 0 2px; font: 700 15px var(--display); }
.map-pop p { margin: 2px 0; color: #555; font-size: 12.5px; }
.map-pop button { margin-top: 6px; border: 0; background: #c8372d; color: #fff; padding: 5px 10px; border-radius: 8px; cursor: pointer; }
.pin {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    background: var(--red);
    color: #fff;
    transform: rotate(-45deg);
    border: 2px solid #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
}
.pin span { transform: rotate(45deg); font-size: 14px; }

/* ---------- Lieux & astuces ---------- */
.city-block { margin-bottom: 34px; }
.city-head { display: flex; align-items: baseline; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-bottom: 12px; }
.city-head h2 { margin: 0; font: 800 26px/1.1 var(--display); }
.city-head span { color: var(--ink-3); font-size: 13px; }
.place-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.place {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    gap: 10px;
    align-items: start;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
}
.place-ico { font-size: 22px; line-height: 1; }
.place h3 { margin: 0; font: 700 15px/1.3 var(--display); }
.place .ja { color: var(--ink-3); font-weight: 500; margin-left: 4px; }
.place p { margin: 3px 0 0; font-size: 13px; color: var(--ink-2); }
.place-actions { display: flex; flex-direction: column; gap: 6px; }
.btn-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    color: var(--ink);
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn-mini:hover { border-color: var(--ink); }
.btn-mini.red { background: var(--red); border-color: var(--red); color: #fff8ef; }

.tip-cat { margin-bottom: 30px; }
.tip-cat h2 { font: 800 22px var(--display); margin: 0 0 10px; }
.tip {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 8px;
}
.tip p { margin: 0; }
.tip small { display: block; color: var(--ink-3); margin-top: 3px; }
.tip small a { color: inherit; }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-3); }
.empty b { display: block; font: 800 40px var(--display); color: var(--line); }

/* ---------- Bouton d'ajout ---------- */
.fab {
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 30;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: var(--red);
    color: #fff8ef;
    font: 500 30px/1 var(--body);
    cursor: pointer;
    box-shadow: 0 8px 24px -6px rgba(200, 55, 45, .6);
}

/* ---------- Fiche détail ---------- */
.modal { position: fixed; inset: 0; z-index: 50; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 12, 8, .55); backdrop-filter: blur(3px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
    position: absolute;
    inset: 3vh 3vw;
    display: grid;
    grid-template-columns: minmax(280px, 420px) 1fr;
    background: var(--paper);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .4);
    animation: pop .3s cubic-bezier(.2, .8, .2, 1);
    max-width: 1200px;
    margin: 0 auto;
}
@keyframes pop { from { opacity: 0; transform: translateY(30px) scale(.98); } }
.sheet-close {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 5;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--card);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.sheet-media { background: #0d0b09; display: flex; flex-direction: column; min-height: 0; }
.sheet-media video, .sheet-media .slide img { width: 100%; height: 100%; object-fit: contain; background: #000; }
.media-main { flex: 1; min-height: 0; position: relative; }
.media-main > * { position: absolute; inset: 0; }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; height: 100%; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slide { flex: none; width: 100%; height: 100%; scroll-snap-align: center; position: relative; }
.slide video { position: absolute; inset: 0; }
.slide-dots { display: flex; justify-content: center; gap: 6px; padding: 10px; }
.slide-dots i { width: 7px; height: 7px; border-radius: 50%; background: #5a5147; }
.slide-dots i.on { background: #fff; }

.sheet-body { overflow-y: auto; padding: 26px 30px 40px; -webkit-overflow-scrolling: touch; }
.d-kicker { color: var(--ink-3); font-size: 13px; }
.d-kicker a { color: inherit; }
.sheet-body h2 { margin: 4px 0 10px; font: 800 28px/1.2 var(--display); }
.d-summary { font-size: 15.5px; color: var(--ink-2); }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    cursor: pointer;
    font-weight: 500;
}
.toggle.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.toggle[data-status="fav"].is-on { background: var(--red); border-color: var(--red); color: #fff8ef; }

.d-section { margin-top: 26px; }
.d-section h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    font: 700 13px var(--body);
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-3);
}
.d-section h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.d-section ul { margin: 0; padding-left: 20px; }
.d-section li { margin-bottom: 6px; }
.note {
    width: 100%;
    min-height: 80px;
    padding: 10px 12px;
    border: 1.5px dashed var(--line);
    border-radius: 12px;
    background: var(--card);
    resize: vertical;
    font: inherit;
}
.note:focus { outline: none; border-style: solid; border-color: var(--ink-2); }
.note-state { font-size: 12px; color: var(--ink-3); height: 16px; }

.transcript { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.tline {
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
    font-size: 14px;
    transition: background .15s;
}
.tline:hover { background: var(--paper-2); }
.tline time { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 12.5px; padding-top: 1px; }
.tline.is-now { background: var(--red-soft); }
.tline.is-now time { color: var(--red); font-weight: 700; }
.tline .tr { display: block; color: var(--ink-3); font-size: 13px; }
.caption-raw { white-space: pre-wrap; font-size: 13.5px; color: var(--ink-2); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; max-height: 300px; overflow-y: auto; }
details summary { cursor: pointer; color: var(--ink-2); font-weight: 500; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
    .top { grid-template-columns: 1fr auto; }
    .search { grid-column: 1 / -1; grid-row: 2; max-width: none; }
    .search kbd { display: none; }
    .views { grid-column: 1 / -1; grid-row: 3; justify-content: space-between; }
    .view-btn { flex: 1; padding: 7px 6px; }
    .brand h1 { font-size: 19px; }
    .brand-kanji { width: 40px; height: 40px; font-size: 22px; }
    .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .card-title { font-size: 14px; }
    .card-body { padding: 10px; }
    .stamps { display: none; }
    .sheet { inset: 0; border-radius: 0; grid-template-columns: 1fr; grid-template-rows: 58vh auto; overflow-y: auto; }
    .sheet-media { position: sticky; top: 0; z-index: 2; }
    .sheet-body { overflow: visible; padding: 20px 16px 60px; }
    .sheet-body h2 { font-size: 23px; }
    #map { height: calc(100vh - 290px); }
    .place-list { grid-template-columns: 1fr; }
}
