/* 予約サイトの共通スタイル。色・文字はここの変数から作る（湯布院の朝霧・杉・宿の灯り） */
:root {
    --mist: #eef2f1; /* 背景：朝霧 */
    --surface: #ffffff;
    --ink: #1f2a33; /* 文字：夜の山影 */
    --muted: #5b6b73;
    --line: #d3dcda;
    --cedar: #2f5d50; /* 主色：杉 */
    --cedar-deep: #23463c;
    --cedar-soft: #e1ebe7;
    --lamp: #d9a441; /* 灯り：自分の泊まる夜だけに使う */
    --lamp-soft: #f6e7c4;
    --danger: #b3412e;
    --danger-soft: #f7e3df;
    --warn: #8a5a00;
    --warn-soft: #fbf1d9;

    --font-display: "Zen Old Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
    --font-body: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

    --radius: 10px;
    --gutter: 16px;
    --max: 720px;
}

* {
    box-sizing: border-box;
}

/* hidden 属性は、display を持つクラス（.button など）より優先する */
[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--mist);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
}

a {
    color: var(--cedar);
}

:focus-visible {
    outline: 3px solid var(--lamp);
    outline-offset: 2px;
}

/* ---------- 枠 ---------- */

.site-header {
    background: var(--cedar-deep);
    color: #fff;
}

.site-header__inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: 14px var(--gutter);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.site-header__inner--wide {
    max-width: 1120px;
}

.site-header__name {
    font-family: var(--font-display);
    font-size: 1.15rem;
    letter-spacing: 0.08em;
    color: #fff;
    text-decoration: none;
}

.site-header__nav {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* 狭い画面: 施設名の下に、メニューを1行で（はみ出したら横に送る） */
@media (max-width: 560px) {
    .site-header__inner {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    .site-header__nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }
}

.site-header__nav a,
.site-header__nav button {
    color: #dfe9e5;
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

.site-header__nav a:hover,
.site-header__nav button:hover {
    color: #fff;
    text-decoration: underline;
}

main {
    max-width: var(--max);
    margin: 0 auto;
    padding: 24px var(--gutter) 64px;
}

main.wide {
    max-width: 1120px;
}

h1,
h2,
h3 {
    line-height: 1.4;
    margin: 0 0 12px;
}

h1 {
    font-size: 1.4rem;
}

h2 {
    font-size: 1.1rem;
    margin-top: 32px;
}

.lead {
    color: var(--muted);
    margin: 0 0 20px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}

.stack > * + * {
    margin-top: 16px;
}

/* ---------- 部品 ---------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 20px;
    font: inherit;
    font-weight: 700;
    color: #fff;
    background: var(--cedar);
    border: 1px solid var(--cedar);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
}

.button:hover {
    background: var(--cedar-deep);
}

.button:disabled {
    opacity: 0.5;
    cursor: default;
}

.button--quiet {
    color: var(--cedar);
    background: var(--surface);
}

.button--quiet:hover {
    background: var(--cedar-soft);
}

.button--danger {
    color: var(--danger);
    background: var(--surface);
    border-color: var(--danger);
}

.button--danger:hover {
    background: var(--danger-soft);
}

.button--block {
    width: 100%;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}

.hint {
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="time"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.field + .field {
    margin-top: 16px;
}

.field-error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 4px;
}

.notice {
    padding: 12px 16px;
    border-radius: 8px;
    background: var(--cedar-soft);
    border-left: 4px solid var(--cedar);
}

.notice--error {
    background: var(--danger-soft);
    border-left-color: var(--danger);
}

.notice--warn {
    background: var(--warn-soft);
    border-left-color: var(--lamp);
    color: var(--warn);
}

.notice:empty {
    display: none;
}

/* 画面上部の結果・エラーの欄 */
#message:not(:empty) {
    margin-bottom: 16px;
}

.mono {
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

.status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--cedar-soft);
    color: var(--cedar-deep);
    white-space: nowrap;
}

.status--wait {
    background: var(--warn-soft);
    color: var(--warn);
}

.status--done {
    background: #e7eaec;
    color: var(--muted);
}

.status--stop {
    background: var(--danger-soft);
    color: var(--danger);
}

.empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted);
}

/* ---------- 鍵札（予約の札） ---------- */
/* 宿の鍵札のかたち。左に穴、杉の縁。日程を大きく、予約番号と状態を添える */

.key-tag {
    position: relative;
    display: grid;
    grid-template-columns: 44px 1fr;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px 6px 6px 14px;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
}

.key-tag::before {
    /* 杉の縁 */
    content: "";
    grid-row: 1 / span 2;
    background: var(--cedar);
}

.key-tag::after {
    /* 紐を通す穴 */
    content: "";
    position: absolute;
    left: 14px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border-radius: 50%;
    background: var(--mist);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

.key-tag__body {
    padding: 16px 18px;
}

.key-tag__dates {
    font-family: var(--font-display);
    font-size: 1.3rem;
    letter-spacing: 0.04em;
    line-height: 1.4;
}

.key-tag__dates small {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--muted);
    margin-left: 6px;
}

.key-tag__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin-top: 8px;
    font-size: 0.875rem;
    color: var(--muted);
}

a.key-tag:hover {
    border-color: var(--cedar);
}

.key-tag--past::before {
    background: #a9b5b9;
}

.key-tag-list {
    display: grid;
    gap: 12px;
}

/* ---------- カレンダー（空き状況） ---------- */

.calendar {
    display: grid;
    gap: 24px;
}

.calendar__month h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.calendar__grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar__dow {
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
    padding-bottom: 2px;
}

.night {
    position: relative;
    aspect-ratio: 1 / 1;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-size: 0.95rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    padding: 0;
}

.night small {
    font-size: 0.6rem;
    line-height: 1.1;
    color: var(--muted);
}

.night:disabled {
    cursor: default;
    background: transparent;
    border-color: transparent;
    color: #9aa7ab;
}

.night--booked:disabled {
    background: repeating-linear-gradient(-45deg, #e3e8e7 0 4px, #eef2f1 4px 8px);
    border-color: var(--line);
}

.night--offday:not(:disabled) {
    border-style: dashed;
    color: var(--muted);
}

.night--selected {
    background: var(--lamp-soft);
    border-color: var(--lamp);
}

.night--edge {
    background: var(--lamp);
    border-color: var(--lamp);
    color: var(--ink);
    font-weight: 700;
}

.night--edge small,
.night--selected small {
    color: var(--ink);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.legend span {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: -2px;
    margin-right: 4px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.legend .is-booked {
    background: repeating-linear-gradient(-45deg, #e3e8e7 0 3px, #eef2f1 3px 6px);
}

.legend .is-offday {
    border-style: dashed;
}

.legend .is-mine {
    background: var(--lamp);
    border-color: var(--lamp);
}

/* 選んだ日程のまとめ（画面下に固定） */
.selection-bar {
    position: sticky;
    bottom: 0;
    margin: 24px calc(-1 * var(--gutter)) -64px;
    padding: 16px var(--gutter) calc(16px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 3px solid var(--lamp);
    box-shadow: 0 -4px 16px rgba(31, 42, 51, 0.08);
}

/* ---------- 表（管理画面） ---------- */

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 700;
    background: #f6f8f8;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr.is-active td {
    background: var(--lamp-soft);
}

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tabs button {
    font: inherit;
    padding: 10px 16px;
    min-height: 44px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: none;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
}

.tabs button[aria-selected="true"] {
    color: var(--cedar-deep);
    border-bottom-color: var(--cedar);
    font-weight: 700;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.filters .field {
    margin: 0;
    min-width: 150px;
}

dl.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 16px;
    margin: 0;
}

dl.facts dt {
    color: var(--muted);
    font-size: 0.875rem;
}

dl.facts dd {
    margin: 0;
}

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.875rem;
}

.timeline li {
    padding: 6px 0 6px 16px;
    border-left: 2px solid var(--line);
}

.timeline time {
    color: var(--muted);
    margin-right: 8px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- スタッフの画面 ---------- */
/* 宿泊者の画面と取り違えないよう、ヘッダーの色を変える（夜の山影） */
.site-header--staff {
    background: var(--ink);
}

.site-header__who {
    margin-left: auto;
    font-size: 0.8rem;
    color: #c7d1d4;
}

.perm-table th,
.perm-table td {
    text-align: center;
    padding: 6px 8px;
}

.perm-table th:first-child,
.perm-table td:first-child {
    text-align: left;
}

.perm-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.secret {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    letter-spacing: 0.06em;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px dashed var(--lamp);
    border-radius: 6px;
    display: inline-block;
    user-select: all;
}
