/* シンプル・白基調・余白多め・レスポンシブ */
:root {
    --text: #222;
    --muted: #777;
    --line: #e5e5e5;
    --accent: #2563eb;
    --danger: #c0392b;
    --bg: #fff;
    --bg-soft: #f7f7f7;
    /* ごく薄い水色(上部の帯とウエルカムページの背景) */
    --header-bg: #eaf4fb;
    --header-line: #d3e6f3;
    --header-text: #2a4a63;
    --welcome-bg: #f3f9fd;
}

*, *::before, *::after { box-sizing: border-box; }
/* hidden 属性の付いた要素は、ほかの指定(button { display: … } など)より優先して隠す */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
    line-height: 1.8;
}

a { color: var(--accent); }

.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 48px 20px 80px;
}

h1 { font-size: 1.8rem; line-height: 1.4; margin: 0 0 32px; }
h2 { font-size: 1.3rem; line-height: 1.4; margin: 40px 0 16px; }

.muted { color: var(--muted); font-size: 0.9rem; }
.notice { padding: 16px; background: var(--bg-soft); border-radius: 6px; }
.error { color: var(--danger); }

/* 上部の帯(サイト名。リンクなし) */
.site-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-line);
}
/* サイト名は画面の左端寄りに置く(本文の幅にはそろえない) */
.site-header-inner {
    padding: 14px 28px;
}
.site-name {
    color: var(--header-text);
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
}

/* ウエルカムページ */
body.welcome { background: var(--welcome-bg); }
body.welcome .container {
    min-height: 100vh;
    max-width: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.welcome-title {
    margin: 0;
    font-size: clamp(3rem, 12vw, 8rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
}

/* 一覧 */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { padding: 20px 0; border-bottom: 1px solid var(--line); }
.list > li:first-child { border-top: 1px solid var(--line); }

/* ブログ */
.post-title { font-size: 1.2rem; margin: 0 0 4px; }
.post-title a { color: var(--text); text-decoration: none; }
.post-title a:hover { text-decoration: underline; }
.excerpt { margin: 8px 0 0; color: #444; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tag {
    display: inline-block;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text);
    text-decoration: none;
}
.tag.active { background: var(--text); color: #fff; border-color: var(--text); }
.toolbar { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 24px; }
.pager { display: flex; justify-content: space-between; margin-top: 32px; }
.post-body img { max-width: 100%; height: auto; }
.post-body pre { overflow-x: auto; background: var(--bg-soft); padding: 12px; border-radius: 6px; }
.post-body code { font-size: 0.9em; }
.post-body blockquote { margin: 0; padding-left: 16px; border-left: 3px solid var(--line); color: #555; }

/* ファイル共有 */
.file-row { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.file-row a { word-break: break-all; }
.size { white-space: nowrap; }

/* フォーム・ボタン */
label { display: block; font-weight: 600; margin: 20px 0 6px; }
input[type="text"], input[type="password"], input[type="datetime-local"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font: inherit;
    background: #fff;
}
textarea { min-height: 360px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.95rem; }
.button, button {
    display: inline-block;
    padding: 8px 18px;
    border: 1px solid var(--text);
    border-radius: 6px;
    background: var(--text);
    color: #fff;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}
.button.secondary, button.secondary { background: #fff; color: var(--text); }
.button.danger, button.danger { background: var(--danger); border-color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; align-items: center; }
.inline-form { display: inline; }
.preview { margin-top: 24px; padding: 20px; border: 1px dashed #ccc; border-radius: 6px; }
/* 管理画面の上部: ユーザー情報(右寄せ)と、記事・共有ファイルの切り替えタブ */
.admin-bar { display: grid; gap: 16px; margin-bottom: 32px; }
.admin-user { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 12px; }
.admin-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--header-line); }
.admin-tab {
    margin-bottom: -1px;             /* 選択中のタブを下の線とつなげる */
    padding: 8px 22px;
    border: 1px solid var(--line);
    border-bottom-color: var(--header-line);
    border-radius: 8px 8px 0 0;
    background: var(--bg-soft);
    color: var(--muted);
    text-decoration: none;
}
.admin-tab:hover { background: var(--header-bg); color: var(--header-text); }
.admin-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.admin-tab.is-active {
    border-color: var(--header-line);
    border-bottom-color: var(--bg);
    background: var(--bg);
    color: var(--text);
    font-weight: 600;
}

/* 共有ファイルの管理(ファイルマネージャ型) */
body.wide .container { max-width: 1200px; }
.fm { display: grid; gap: 12px; }
.fm-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    padding: 10px 12px;
    background: var(--header-bg);
    border: 1px solid var(--header-line);
    border-radius: 8px;
}
.fm-btn {
    padding: 6px 12px;
    border: 1px solid var(--header-line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--header-text);
    font-size: 0.9rem;
}
.fm-btn:hover:not(:disabled) { background: #f3f9fd; border-color: #b9d6ea; }
.fm-btn:disabled { color: #a9b6c0; border-color: var(--line); background: #f8fafb; cursor: not-allowed; }
.fm-btn-danger:not(:disabled) { color: var(--danger); }
.fm-sep { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--header-line); }
.fm-overwrite { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 0 auto; font-weight: normal; font-size: 0.85rem; color: var(--header-text); }
.fm-body { display: grid; grid-template-columns: 220px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 8px; min-height: 420px; }
.fm-tree { border-right: 1px solid var(--line); background: #fafbfc; padding: 10px 6px; overflow-x: auto; border-radius: 8px 0 0 8px; }
.fm-tree ul { list-style: none; margin: 0; padding: 0; }
.fm-tree ul ul { padding-left: 14px; }
.fm-tree-row { display: flex; align-items: center; gap: 2px; border-radius: 4px; white-space: nowrap; }
.fm-tree-row a { color: var(--text); text-decoration: none; padding: 2px 6px; border-radius: 4px; }
.fm-tree-row a:hover { background: var(--header-bg); }
.fm-tree-row.is-current a { background: var(--header-bg); color: var(--header-text); font-weight: 600; }
.fm-tree-toggle { width: 22px; padding: 0; border: none; background: none; color: var(--muted); font-size: 0.8rem; }
.fm-tree-toggle.is-leaf { visibility: hidden; }
.fm-main { position: relative; padding: 12px 16px 16px; min-width: 0; }
.fm-main.is-dragover { outline: 2px dashed var(--accent); outline-offset: -6px; background: #f5faff; }
.fm-path { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; margin-bottom: 8px; font-size: 0.95rem; }
.fm-path-sep { color: var(--muted); }
.fm-table-wrap { overflow-x: auto; }
.fm-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.fm-table th { text-align: left; font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; }
.fm-table td { padding: 6px 8px; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }
.fm-table td:nth-child(2) { white-space: normal; word-break: break-all; }
.fm-table tbody tr { cursor: default; }
.fm-table tbody tr:hover { background: #f7fafc; }
.fm-table tbody tr.is-selected { background: var(--header-bg); }
.fm-col-check { width: 32px; }
.fm-col-id { width: 88px; }
.fm-chapter-info { margin: -4px 0 8px; font-size: 0.85rem; }
.fm-field { margin-bottom: 4px; }
.fm-field label { margin: 12px 0 4px; }
.fm-field-note { margin: 4px 0 0; font-size: 0.85rem; }
.fm-col-size { text-align: right; font-variant-numeric: tabular-nums; }
.fm-col-date { font-variant-numeric: tabular-nums; color: #555; }
.fm-col-type { color: #555; }
.fm-sort { padding: 0; border: none; background: none; color: var(--text); font: inherit; font-weight: 600; }
.fm-sort::after { content: " ⇅"; color: #bbb; font-weight: normal; }
.fm-sort[data-dir="asc"]::after { content: " ▲"; color: var(--header-text); }
.fm-sort[data-dir="desc"]::after { content: " ▼"; color: var(--header-text); }
.fm-name::before { display: inline-block; width: 1.4em; color: #c9a227; }
.fm-folder::before { content: "■"; }
.fm-file::before { content: "□"; color: #8aa4b8; }
.fm-folder { color: var(--text); font-weight: 600; text-decoration: none; }
.fm-folder:hover { text-decoration: underline; }
.fm-empty { margin: 16px 0 0; color: var(--muted); }
.fm-drop-hint { margin: 16px 0 0; font-size: 0.85rem; }
.fm-status { padding: 12px 16px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; font-size: 0.9rem; }
.fm-status.is-error { border-color: #f0c4bf; background: #fdf4f3; }
.fm-status-head { display: flex; justify-content: space-between; gap: 12px; }
.fm-status-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 240px; overflow-y: auto; }
.fm-status-list li { padding: 3px 0; border-bottom: 1px solid var(--line); word-break: break-all; }
.fm-link { padding: 0; border: none; background: none; color: var(--accent); font: inherit; text-decoration: underline; }
.fm-dialog { width: min(480px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; }
.fm-dialog::backdrop { background: rgba(20, 40, 60, 0.35); }
.fm-dialog h2 { margin: 0 0 12px; font-size: 1.15rem; }
.fm-dialog-items { max-height: 160px; overflow-y: auto; margin: 0 0 8px; padding-left: 20px; word-break: break-all; }
.fm-picker { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.fm-picker-path { font-weight: 600; margin-bottom: 6px; word-break: break-all; }
.fm-picker-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.fm-picker-list li { padding: 3px 0; }

/* 表(管理画面) */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }

@media (max-width: 600px) {
    .container { padding: 32px 16px 64px; }
    .site-header-inner { padding: 10px 16px; }
    .site-name { font-size: 1.6rem; }
    /* 共有ファイルの管理: スマホではフォルダの木と、一部の列を隠す */
    .fm-body { grid-template-columns: minmax(0, 1fr); }
    .fm-tree { display: none; }
    .fm-col-type, .fm-col-date { display: none; }
    .fm-overwrite { margin-left: 0; }
    .fm-main { padding: 10px; }
    h1 { font-size: 1.5rem; }
    .table thead { display: none; }
    .table td { display: block; border: none; padding: 2px 0; }
    .table tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
}

/* ターミナル用のコマンド */
pre.command {
    margin: 8px 0 16px;
    padding: 12px 14px;
    background: #1f2328;
    color: #f0f0f0;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.6;
}
details summary { cursor: pointer; font-size: 0.85rem; margin-top: 4px; }

/* ダウンロード用ID(例: SMP0301) */
.share-id {
    display: inline-block;
    padding: 0 6px;
    border: 1px solid var(--header-line);
    border-radius: 4px;
    background: var(--header-bg);
    color: var(--header-text);
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.03em;
    vertical-align: 0.1em;
}

/* プレビュー */
.link-button { padding: 0; border: none; background: none; color: var(--accent); font: inherit; font-size: 0.9rem; text-decoration: underline; cursor: pointer; }
.file-meta { display: inline-flex; align-items: baseline; gap: 14px; white-space: nowrap; }
.pv {
    width: min(1000px, calc(100vw - 24px));
    height: min(86vh, 900px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
}
.pv[open] { display: flex; flex-direction: column; }
.pv::backdrop { background: rgba(20, 40, 60, 0.45); }
.pv-head {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px;
    padding: 10px 16px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-line);
}
.pv-title { margin: 0; font-size: 1rem; word-break: break-all; color: var(--header-text); }
.pv-actions { display: flex; gap: 8px; }
.pv-actions .button, .pv-actions button { padding: 4px 14px; font-size: 0.9rem; }
.pv-body { flex: 1; min-height: 0; overflow: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.pv-image { max-width: 100%; max-height: 100%; object-fit: contain; margin: auto; }
.pv-frame { flex: 1; width: 100%; min-height: 60vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pv-media { width: 100%; max-height: 100%; margin: auto 0; }
.pv-text { margin: 0; padding: 12px; background: var(--bg-soft); border-radius: 6px; font-size: 0.85rem; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.pv-note { margin: 0; font-size: 0.85rem; }
.pv-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.pv-tabs button { padding: 4px 12px; font-size: 0.85rem; }
.pv-tabs button.is-active { background: var(--text); color: #fff; }
.pv-sheet { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
