/* =====================================================================
   Psychology Research Lab Wiki — Friendly Edition v3
   - 白背景 + 柔らかなアクセントカラー
   - 親しみやすいサンセリフ、丸み、控えめなシャドウ
   - 脳の絵文字なし、.main を左寄せ
   - 元のセレクタ／変数名はすべて維持
   ===================================================================== */

:root {
    --bg: #ffffff;
    --panel: #f8fafc;
    --ink: #2d3748;
    --sub: #718096;
    --line: #e8edf3;
    --accent: #6a9bd1;
    --accent-soft: #eef4fb;
    --warn: #e89a6b;
    --radius: 10px;

    --font-body: "Hiragino Maru Gothic ProN", "Yu Gothic", "Noto Sans JP",
        "Hiragino Sans", "Avenir Next", "Helvetica Neue",
        Arial, sans-serif;
    --font-mono: "SF Mono", "Menlo", Consolas, monospace;

    --soft-shadow: 0 2px 8px rgba(45, 55, 72, 0.06),
        0 1px 3px rgba(45, 55, 72, 0.04);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.7;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
}

.layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 28px 20px;
}

.sidebar .brand {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.sidebar .brand small {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--sub);
    letter-spacing: 0.02em;
    margin-top: 4px;
}

.sidebar .brand a {
    color: var(--ink);
    display: block;
}

.sidebar .brand-logo {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius);
}

.sidebar form.search {
    margin: 22px 0 18px;
}

.sidebar input[type=text] {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar input[type=text]::placeholder {
    color: var(--sub);
}

.sidebar input[type=text:focus] {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.sidebar nav {
    margin-bottom: 6px;
}

.sidebar nav a {
    display: block;
    padding: 8px 12px;
    border-radius: var(--radius);
    color: var(--ink);
    font-size: 14.5px;
    transition: background 0.12s ease, color 0.12s ease;
}

.sidebar nav a:hover {
    background: var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
}

.sidebar .section-title {
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0.02em;
    color: var(--sub);
    margin: 22px 0 8px;
    font-weight: 600;
}

.sidebar .section-title::before {
    content: "✎ ";
    color: var(--accent);
}

.tag-cloud,
.book-list,
.recent-list {
    margin-bottom: 8px;
}

.tag-cloud a,
.book-list a {
    display: inline-block;
    font-size: 13px;
    padding: 4px 11px;
    margin: 3px 5px 3px 0;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    transition: all 0.12s ease;
    font-weight: 500;
}

.tag-cloud a:hover,
.book-list a:hover {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
}

.recent-list {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
}

.recent-list li {
    font-size: 13.5px;
    padding: 3px 0;
}

.recent-list li a {
    color: var(--ink);
}

.recent-list li a:hover {
    color: var(--accent);
}

/* --- 左寄せ: margin: 0 auto を除去 --- */
.main {
    padding: 40px 48px 60px;
    max-width: none;
    margin: 0;
    text-align: left;
}

.crumbs {
    font-size: 13px;
    color: var(--sub);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.crumbs a {
    color: var(--sub);
}

.crumbs a:hover {
    color: var(--accent);
}

h1.page-title {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 10px;
    letter-spacing: 0.005em;
    color: var(--ink);
}

.page-meta {
    font-size: 13px;
    line-height: 1.6;
    color: var(--sub);
    margin-bottom: 28px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.page-meta::before {
    content: "📅 ";
    margin-right: -4px;
}

.page-meta .tag {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 999px;
    margin-right: 4px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.12s ease;
}

.page-meta .tag:hover {
    background: var(--accent);
    color: #fff;
}

.content {
    font-size: 15.5px;
    line-height: 1.85;
    text-align: left;
}

.content p {
    margin: 0.8em 0;
}

.content h1,
.content h2,
.content h3 {
    margin: 1.3em 0 0.4em;
    font-weight: 700;
    line-height: 1.4;
    color: var(--ink);
}

.content h1:first-child,
.content h2:first-child,
.content h3:first-child {
    margin-top: 0;
}

.content h1 {
    font-size: 26px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-soft);
}

.content h2 {
    font-size: 21px;
    padding-left: 4px;
}

.content h2::before {
    content: "■";
    color: var(--accent);
    margin-right: 8px;
    font-size: 0.7em;
    vertical-align: middle;
}

.content h3 {
    font-size: 18px;
    color: var(--accent);
}

.content pre {
    background: var(--panel);
    padding: 16px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13.5px;
    box-shadow: var(--soft-shadow);
    text-align: left;
}

.content code {
    font-family: var(--font-mono);
    background: var(--accent-soft);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
}

.content img {
    max-width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--soft-shadow);
}

.content figure {
    margin: 1.2em 0;
}

.content figcaption {
    font-size: 13px;
    color: var(--sub);
    text-align: left;
    margin-top: 8px;
}

.content blockquote {
    border-left: 4px solid var(--accent);
    margin: 1.2em 0;
    padding: 14px 20px;
    color: var(--ink);
    background: var(--accent-soft);
    border-radius: 0 var(--radius) var(--radius) 0;
    position: relative;
    text-align: left;
}

.content blockquote::before {
    content: "\201C";
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 28px;
    color: var(--accent);
    opacity: 0.4;
    font-family: serif;
    line-height: 1;
}

.content blockquote p:first-child {
    margin-top: 4px;
}

.content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0.9em 0;
    font-size: 14px;
    line-height: 1.6;
    background: var(--bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--soft-shadow);
    border: 1px solid var(--line);
    text-align: left;
}

.content th,
.content td {
    padding: 10px 14px;
    line-height: 1.6;
    text-align: left;
    vertical-align: top;
    border: none;
    border-bottom: 1px solid var(--line);
}

.content tbody tr:last-child td {
    border-bottom: none;
}

.content th {
    font-weight: 700;
    background: var(--panel);
    color: var(--ink);
    font-size: 13px;
}

.content tbody tr {
    transition: background 0.1s ease;
}

.content tbody tr:hover {
    background: var(--accent-soft);
}

.content tbody tr:nth-child(even) {
    background: rgba(238, 244, 251, 0.4);
}

.content tbody tr:nth-child(even):hover {
    background: var(--accent-soft);
}

a.wikilink-new {
    color: var(--warn);
    border-bottom: 1.5px dashed var(--warn);
    transition: color 0.15s ease;
}

a.wikilink-new:hover {
    color: #c97b4f;
}

.toolbar {
    margin: 22px 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius);
    border: 1.5px solid var(--line);
    background: var(--bg);
    color: var(--ink);
    font-size: 13.5px;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 500;
}

.btn:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

.btn.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 2px 6px rgba(106, 155, 209, 0.3);
}

.btn.primary:hover {
    background: #5489bf;
    border-color: #5489bf;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(106, 155, 209, 0.4);
}

.btn.danger {
    color: var(--warn);
    border-color: var(--warn);
}

.btn.danger:hover {
    background: var(--warn);
    color: #fff;
    border-color: var(--warn);
}

table.page-list {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

table.page-list th,
table.page-list td {
    text-align: left;
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    font-size: 14.5px;
    transition: background 0.1s ease;
}

table.page-list tbody tr:hover td {
    background: var(--accent-soft);
}

table.page-list th {
    font-size: 12px;
    text-transform: none;
    color: var(--sub);
    letter-spacing: 0.04em;
    font-weight: 600;
    background: var(--panel);
}

form.editform label {
    display: block;
    font-size: 14px;
    color: var(--ink);
    margin: 18px 0 8px;
    font-weight: 600;
}

form.editform input[type=text],
form.editform textarea,
form.editform select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    font-size: 14.5px;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

form.editform input[type=text]:focus,
form.editform textarea:focus,
form.editform select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

form.editform textarea {
    font-family: var(--font-mono);
    font-size: 14px;
    min-height: 420px;
    resize: vertical;
}

form.editform .row {
    display: flex;
    gap: 16px;
}

form.editform .row>div {
    flex: 1;
}

.hint {
    font-size: 12.5px;
    color: var(--sub);
    margin-top: 6px;
}

.badge-protected {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--warn);
    color: #fff;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    margin-left: 8px;
    font-weight: 500;
}

.badge-protected::before {
    content: "🔒";
    font-size: 11px;
}

.page-actions {
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1.5px solid var(--line);
    background: var(--bg);
    color: var(--ink);
    font-size: 13.5px;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.15s ease;
}

.page-actions:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.toc {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 22px;
    margin: 20px 0 28px;
    display: inline-block;
    min-width: 260px;
    box-shadow: var(--soft-shadow);
    text-align: left;
}

.toc-title {
    font-size: 13px;
    text-transform: none;
    letter-spacing: 0.02em;
    color: var(--accent);
    margin-bottom: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.toc-title::before {
    content: "📑";
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-list li {
    font-size: 14px;
    padding: 4px 0;
}

.toc-list li a {
    color: var(--ink);
    transition: color 0.12s ease;
    border-bottom: none;
}

.toc-list li a:hover {
    color: var(--accent);
}

.toc-level-1 {
    padding-left: 0;
    font-weight: 600;
}

.toc-level-2 {
    padding-left: 16px;
    color: var(--sub);
    font-size: 13.5px;
}

.toc-level-3 {
    padding-left: 32px;
    color: var(--sub);
    font-size: 13px;
}

.empty {
    color: var(--sub);
    padding: 60px 20px;
    text-align: center;
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.empty::before {
    content: "📝";
    display: block;
    font-size: 32px;
    margin-bottom: 12px;
}

.auth-box {
    max-width: 380px;
    margin: 80px auto;
    background: var(--bg);
    padding: 36px 32px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: var(--soft-shadow);
    text-align: left;
}

.auth-box h2 {
    margin-top: 0;
    font-size: 22px;
    color: var(--ink);
    margin-bottom: 6px;
}

.auth-box h2::before {
    content: "👋 ";
}

.auth-box p {
    color: var(--sub);
    font-size: 14px;
    margin-bottom: 24px;
}

.flash {
    background: var(--accent-soft);
    color: var(--ink);
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 8px;
}

.flash::before {
    content: "💡";
    font-size: 16px;
}

.flash.error {
    background: #fef0e7;
    color: #b56840;
    border-color: #f9d9bf;
}

.flash.error::before {
    content: "⚠️";
}

.history-list {
    list-style: none;
    padding: 0;
    text-align: left;
}

.history-list li {
    padding: 11px 6px;
    border-bottom: 1px solid var(--line);
    font-size: 14.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-list li::before {
    content: "📌 ";
    margin-right: 6px;
}

.history-list li:last-child {
    border-bottom: none;
}

.backlinks {
    margin-top: 44px;
    padding-top: 22px;
    text-align: left;
}

.backlinks-divider {
    border: none;
    border-top: 1px solid var(--line);
    margin: 0 0 18px;
}

.backlinks h3 {
    color: var(--accent);
    font-size: 16px;
    margin: 0 0 10px;
}

.backlinks h3::before {
    content: "🔗 ";
}

.backlinks ul {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
}

.backlinks li {
    padding: 5px 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.backlinks li::before {
    content: "→";
    color: var(--accent);
    font-weight: 700;
}

.diff {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 18px;
    font-family: var(--font-mono);
    font-size: 13.5px;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    box-shadow: var(--soft-shadow);
    text-align: left;
}

.diff-same {
    color: var(--ink);
}

.diff-del {
    color: #b56840;
    background: #fef0e7;
    text-decoration: line-through;
    border-radius: 3px;
    padding: 1px 3px;
}

.diff-add {
    color: #4a8c6e;
    background: #e8f3ed;
    border-radius: 3px;
    padding: 1px 3px;
}

.edit-tabs {
    display: flex;
    gap: 4px;
    margin: 14px 0 0;
}

.edit-tab {
    padding: 8px 18px;
    font-size: 14px;
    border: 1.5px solid var(--line);
    background: var(--bg);
    color: var(--sub);
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 500;
    transition: all 0.15s ease;
}

.edit-tab:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.edit-tab.active {
    background: var(--bg);
    color: var(--accent);
    font-weight: 700;
    border-color: var(--accent);
    position: relative;
    z-index: 1;
}

.edit-pane {
    border: 1.5px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    padding: 0;
    background: var(--bg);
    text-align: left;
}

.edit-pane.content {
    padding: 18px 22px;
    min-height: 220px;
    background: var(--bg);
}

.edit-pane textarea {
    border: none;
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    margin: 0;
    width: 100%;
}

.edit-pane textarea:focus {
    outline: none;
}

.wikilink-suggest {
    position: absolute;
    z-index: 10;
    bottom: 10px;
    left: 10px;
    max-width: 320px;
    max-height: 200px;
    overflow-y: auto;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(45, 55, 72, 0.12);
    text-align: left;
}

.wikilink-suggest li {
    padding: 8px 12px;
    font-size: 13.5px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s ease;
}

.wikilink-suggest li:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

/* --- ブック内ナビゲーション（前へ／次へ） --- */
.book-nav {
    margin-top: 32px;
    padding: 16px 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--soft-shadow);
    text-align: left;
}

.book-nav-info {
    font-size: 12.5px;
    color: var(--sub);
    margin-bottom: 10px;
    font-weight: 500;
}

.book-nav-info a {
    color: var(--accent);
}

.book-nav-links {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.book-nav-prev,
.book-nav-next {
    font-size: 14px;
    padding: 6px 4px;
    max-width: 48%;
    font-weight: 500;
}

.book-nav-next {
    text-align: right;
    margin-left: auto;
}

.book-nav-disabled {
    font-size: 14px;
    color: var(--sub);
    opacity: 0.5;
}

@media (max-width: 760px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .main {
        padding: 24px 20px;
    }
}
