:root {
    --bg: #14181f;
    --surface: #1d232d;
    --card: #242b37;
    --card-hover: #2c3543;
    --input-bg: #171c24;
    --border: #364152;
    --text: #f3f6fa;
    --text-sub: #9aa6b8;
    --primary: #3b9be8;
    --primary-hover: #2d87d0;
    --green: #22c55e;
    --teal: #14b8a6;
    --danger: #ef4444;
    --amber: #f59e0b;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --card: #ffffff;
    --card-hover: #f8fafc;
    --input-bg: #f8fafc;
    --border: #cbd5e1;
    --text: #182230;
    --text-sub: #556377;
    --primary: #1d6fc2;
    --primary-hover: #155aa0;
    --green: #16a34a;
    --teal: #0d9488;
    --danger: #dc2626;
    --amber: #d97706;
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

.top-nav {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.nav-left,
.nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-home-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.nav-home-link:hover {
    background: rgba(59, 155, 232, 0.12);
}

.nav-title {
    font-size: 1.15rem;
    font-weight: 800;
}

.theme-switcher {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px;
    gap: 2px;
}

.theme-btn {
    border: none;
    background: transparent;
    color: var(--text-sub);
    font-size: 0.76rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
}

.theme-btn.active {
    background: var(--primary);
    color: #fff;
}

.user-badge {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(59, 155, 232, 0.14);
    border: 1px solid rgba(59, 155, 232, 0.35);
    color: var(--primary);
}

.main-container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 20px 16px 60px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    background: var(--card);
    transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
    background: var(--card-hover);
}

.btn:active {
    transform: translateY(1px);
}

.btn-sm {
    padding: 6px 11px;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-green {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.btn-teal {
    background: var(--teal);
    border-color: var(--teal);
    color: #fff;
}

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

.btn-outline {
    background: transparent;
    border-color: var(--primary);
    color: var(--primary);
}

.btn-ghost {
    background: transparent;
}

.text-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 9px 12px;
    font-size: 0.92rem;
    font-family: inherit;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary);
}

.textarea-input {
    resize: vertical;
}

.list-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.search-box-wrap {
    flex: 1;
    min-width: 240px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.search-ico {
    position: absolute;
    left: 11px;
    pointer-events: none;
}

.search-input {
    padding-left: 34px;
}

.list-summary-bar {
    color: var(--text-sub);
    font-size: 0.84rem;
    margin-bottom: 14px;
}

.bldg-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 14px;
}

.bldg-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.bldg-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.bldg-card-top {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.bldg-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--input-bg);
}

.bldg-thumb-placeholder {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    color: var(--text-sub);
}

.bldg-card-title {
    font-size: 1.03rem;
    font-weight: 800;
    margin-bottom: 3px;
}

.bldg-card-addr {
    font-size: 0.82rem;
    color: var(--text-sub);
}

.bldg-card-memo {
    font-size: 0.82rem;
    color: var(--text-sub);
    background: var(--input-bg);
    border-radius: 6px;
    padding: 6px 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bldg-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.count-pill {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(59, 155, 232, 0.14);
    color: var(--primary);
    border: 1px solid rgba(59, 155, 232, 0.25);
}

.match-hint-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.16);
    color: var(--amber);
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.section-card {
    margin-top: 16px;
}

.detail-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.detail-jump-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.detail-hero-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.detail-bldg-title {
    font-size: 1.35rem;
    font-weight: 800;
}

.detail-hero-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.detail-hero-links {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.section-head-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.section-desc {
    color: var(--text-sub);
    font-size: 0.84rem;
    margin-bottom: 12px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.field {
    margin-bottom: 12px;
}

.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-sub);
    margin-bottom: 5px;
}

.req {
    color: var(--danger);
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.photo-tile {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--input-bg);
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.photo-tile:hover {
    border-color: var(--primary);
}

.photo-tile img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
}

.photo-tile-cap {
    padding: 5px 7px;
    font-size: 0.74rem;
    color: var(--text-sub);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-box {
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 18px;
    text-align: center;
    color: var(--text-sub);
    font-size: 0.86rem;
}

.sched-history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sched-history-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    background: var(--input-bg);
}

.sched-history-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.sched-history-title {
    font-size: 1rem;
    font-weight: 800;
}

.sched-history-meta {
    font-size: 0.8rem;
    color: var(--text-sub);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 3px;
}

.sched-history-desc {
    font-size: 0.84rem;
    color: var(--text-sub);
    margin-bottom: 10px;
    white-space: pre-wrap;
}

.sched-history-photos-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.proj-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.proj-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    text-decoration: none;
    color: var(--text);
}

.proj-history-item:hover {
    border-color: var(--primary);
}

.danger-card {
    border-color: rgba(239, 68, 68, 0.35);
}

.danger-actions-row {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.danger-action-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.muted-text {
    font-size: 0.8rem;
    color: var(--text-sub);
}

.load-more-wrap {
    margin-top: 14px;
    text-align: center;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-card {
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-card.modal-wide {
    max-width: 760px;
}

.modal-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-head h2 {
    font-size: 1.05rem;
    font-weight: 800;
}

.btn-icon-close {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: 700;
}

.modal-body {
    padding: 18px;
    overflow-y: auto;
}

.modal-foot {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.photo-preview-stage {
    background: #0b0e14;
    border-radius: 10px;
    padding: 8px;
    text-align: center;
    margin-bottom: 10px;
}

.photo-preview-stage img {
    max-width: 100%;
    max-height: 55vh;
    object-fit: contain;
    border-radius: 6px;
}

.photo-preview-meta {
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-bottom: 10px;
}

.photo-caption-row {
    display: flex;
    gap: 8px;
}

.unlinked-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 46vh;
    overflow-y: auto;
}

.unlinked-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    cursor: pointer;
}

.unlinked-item input[type="checkbox"] {
    margin-top: 4px;
    transform: scale(1.15);
}

.auth-error {
    color: var(--danger);
    font-size: 0.84rem;
    font-weight: 700;
    margin-top: 8px;
}

.toast-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-item {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.toast-item.toast-success {
    border-left-color: var(--green);
}

.toast-item.toast-error {
    border-left-color: var(--danger);
}

@media (max-width: 700px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
    .detail-jump-actions {
        width: 100%;
    }
    .detail-jump-actions .btn {
        flex: 1 1 auto;
    }
}
