:root {
    --bg: #f5f5f5;
    --panel: #ffffff;
    --panel-alt: #faf8ef;
    --border: #d7d7d7;
    --text: #262626;
    --muted: #6d6d6d;
    --link: #b11f24;
    --accent: #d9edf7;
    --success: #dff0d8;
    --danger: #f8d7da;
    --danger-strong: #d9534f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: linear-gradient(180deg, #ece8db 0, #f5f5f5 180px);
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    line-height: 1.5;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
.button-link {
    appearance: none;
    border: 1px solid #a12c2f;
    background: #c93f44;
    color: #fff;
    border-radius: 4px;
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.button-link-secondary,
.link-button {
    background: #f5f5f5;
    color: var(--text);
    border-color: var(--border);
}

.danger-button {
    background: #fff5f5;
    color: #8f1116;
    border: 1px solid #d7a7aa;
}

.link-button {
    padding: 0.45rem 0.75rem;
}

.container {
    width: min(1180px, calc(100% - 1.5rem));
    margin: 0 auto;
}

.site-header {
    background: #b62d32;
    color: #fff;
    border-bottom: 4px solid #8f1f22;
    box-shadow: var(--shadow);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 0;
}

.brand {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
}

.nav-links {
    display: flex;
    gap: 0.85rem;
    flex-wrap: wrap;
}

.nav-links a,
.header-user,
.header-user .link-button {
    color: #fff;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.main-content {
    padding: 1.25rem 0 2rem;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-heading h1,
.panel h2 {
    margin: 0 0 0.4rem;
    font-family: Georgia, "Times New Roman", serif;
}

.page-heading p,
.muted,
.meta-row {
    color: var(--muted);
    margin: 0;
}

.panel,
.auth-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}

.auth-card {
    width: min(460px, calc(100% - 1rem));
}

.guest-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.auth-card h1 {
    margin-top: 0;
    font-family: Georgia, "Times New Roman", serif;
}

.auth-lead {
    margin-bottom: 1rem;
    color: var(--muted);
}

.stack-form,
.inline-filter {
    display: grid;
    gap: 0.9rem;
}

.form-grid,
.filter-grid,
.detail-grid,
.project-grid,
.note-grid,
.dashboard-grid {
    display: grid;
    gap: 1rem;
}

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

.filter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
}

.project-grid,
.note-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-grid,
.dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-grid > .panel:first-child {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 0.35rem;
}

.full-width {
    grid-column: 1 / -1;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="date"],
input[type="number"],
textarea,
select {
    width: 100%;
    border: 1px solid #c8c8c8;
    border-radius: 4px;
    padding: 0.6rem 0.7rem;
    background: #fff;
}

textarea {
    resize: vertical;
}

.form-error {
    color: #8f1116;
}

.flash {
    border-radius: 6px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.flash-success {
    background: var(--success);
    border-color: #bfd7b8;
}

.flash-error {
    background: var(--danger);
    border-color: #e1aeb3;
}

.action-row,
.project-card-head,
.stats-row,
.task-card-head {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.data-table th,
.data-table td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid #e4e4e4;
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: #f6f3ea;
    white-space: nowrap;
}

.inline-form {
    display: flex;
    gap: 0.45rem;
    align-items: center;
}

.strong-link {
    font-weight: 700;
}

.badge,
.stat-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.82rem;
    background: #eee;
    border: 1px solid #ddd;
}

.status-inbox {
    background: #f2f2f2;
}

.status-next {
    background: #d9edf7;
}

.status-doing {
    background: #fcf8e3;
}

.status-blocked {
    background: #f8d7da;
}

.status-done {
    background: #dff0d8;
}

.priority-urgent {
    background: #f8d7da;
}

.priority-high {
    background: #fcf8e3;
}

.priority-normal {
    background: #d9edf7;
}

.priority-low {
    background: #f2f2f2;
}

.is-overdue {
    background: #fff3f3;
}

.empty-state {
    padding: 1rem;
    border: 1px dashed #c8c8c8;
    background: #fafafa;
    border-radius: 6px;
    color: var(--muted);
}

.markdown-body {
    line-height: 1.7;
}

.markdown-body pre {
    background: #222;
    color: #f7f7f7;
    padding: 0.9rem;
    border-radius: 6px;
    overflow-x: auto;
}

.markdown-body code {
    background: #f3f3f3;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid #ddd;
    padding: 0.45rem 0.6rem;
}

.task-list-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
}

.calendar-weekday,
.calendar-cell {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    padding: 0.6rem;
    min-height: 90px;
}

.calendar-weekday {
    background: #f6f3ea;
    font-weight: 700;
    min-height: auto;
}

.calendar-cell {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    color: var(--text);
}

.calendar-cell.is-other-month {
    opacity: 0.6;
}

.calendar-cell.is-selected {
    border-color: #b62d32;
    box-shadow: inset 0 0 0 1px #b62d32;
}

.calendar-date {
    font-weight: 700;
}

.calendar-count {
    color: var(--link);
    font-size: 0.85rem;
}

.calendar-mini-list {
    color: var(--muted);
    font-size: 0.82rem;
}

.preview-body {
    max-height: 11rem;
    overflow: hidden;
}

.comment-list {
    display: grid;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.comment-item {
    border-left: 4px solid #d4d4d4;
    padding-left: 0.8rem;
}

.comment-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

.mobile-cards {
    display: grid;
    gap: 0.8rem;
}

.task-card {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    padding: 0.9rem;
}

@media (max-width: 960px) {
    .filter-grid,
    .project-grid,
    .note-grid,
    .detail-grid,
    .dashboard-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .page-heading,
    .header-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .header-user {
        justify-content: space-between;
    }
}

@media (max-width: 720px) {
    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: block;
    }

    .container {
        width: min(100% - 1rem, 100%);
    }

    .main-content {
        padding-top: 1rem;
    }

    .calendar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
