:root {
    color-scheme: dark;
    --bg: #070b10;
    --panel: #111922;
    --panel-soft: #172230;
    --line: rgba(167, 190, 210, 0.18);
    --text: #edf6ff;
    --muted: #9cafbf;
    --accent: #67d9c3;
    --accent-2: #9fb7ff;
    --watch: #f5c56b;
    --failed: #ff8a7a;
    --stale: #d9b56f;
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 0;
    background: var(--bg);
}

body.quakesignal-page {
    margin: 0;
    min-width: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(103, 217, 195, 0.14), transparent 34rem),
        linear-gradient(180deg, #071018 0%, #080b10 42%, #090c12 100%);
    font-family: "Inter", "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
    line-height: 1.7;
}

a {
    color: inherit;
}

button,
input,
textarea {
    font: inherit;
}

.qs-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.qs-hero {
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(17, 25, 34, 0.95), rgba(12, 20, 28, 0.86));
    box-shadow: var(--shadow);
}

.qs-back {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
}

.qs-kicker {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.qs-hero .qs-kicker {
    margin-top: 28px;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    font-size: clamp(1.65rem, 3.4vw, 3.1rem);
    line-height: 1.14;
    letter-spacing: 0;
}

h2 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.35;
    letter-spacing: 0;
}

.qs-lead {
    max-width: 780px;
    margin: 18px 0 0;
    color: #dcecff;
    font-size: 1.08rem;
}

.qs-warning,
.qs-comment-note {
    margin: 22px 0 0;
    padding: 16px 18px;
    border: 1px solid rgba(245, 197, 107, 0.4);
    border-radius: 12px;
    color: #ffe8ba;
    background: rgba(115, 78, 20, 0.22);
}

.qs-policy,
.qs-state-panel,
.qs-monitor,
.qs-history-grid,
.qs-info-grid,
.qs-related,
.qs-comments,
.qs-return {
    margin-top: 22px;
}

.qs-policy {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.qs-policy span {
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(17, 25, 34, 0.8);
    font-size: 0.78rem;
    font-weight: 800;
}

.qs-monitor,
.qs-history-grid,
.qs-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.qs-tile,
.qs-history-card,
.qs-info-grid article,
.qs-related,
.qs-comments {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(17, 25, 34, 0.9);
    box-shadow: var(--shadow);
}

.qs-tile {
    padding: 22px;
    position: relative;
    overflow: hidden;
}

.qs-tile::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(110deg, rgba(103, 217, 195, 0.08), transparent 34%);
}

.qs-tile.is-watch {
    border-color: rgba(245, 197, 107, 0.55);
}

.qs-tile.is-updated {
    animation: quietPulse 900ms ease-out;
}

@keyframes quietPulse {
    0% { box-shadow: 0 0 0 0 rgba(103, 217, 195, 0.28), var(--shadow); }
    100% { box-shadow: 0 0 0 18px rgba(103, 217, 195, 0), var(--shadow); }
}

.qs-tile-head,
.qs-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.qs-status {
    flex: 0 0 auto;
    padding: 7px 10px;
    border: 1px solid rgba(103, 217, 195, 0.42);
    border-radius: 999px;
    color: var(--accent);
    background: rgba(103, 217, 195, 0.08);
    font-size: 0.72rem;
    font-weight: 900;
}

.qs-status.is-stale {
    color: var(--stale);
    border-color: rgba(217, 181, 111, 0.48);
    background: rgba(217, 181, 111, 0.1);
}

.qs-status.is-failed {
    color: var(--failed);
    border-color: rgba(255, 138, 122, 0.5);
    background: rgba(255, 138, 122, 0.09);
}

.qs-latest {
    position: relative;
    margin-top: 28px;
}

.qs-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.qs-latest strong {
    display: block;
    margin-top: 6px;
    font-size: clamp(1.45rem, 4vw, 2.4rem);
    line-height: 1.2;
}

.qs-latest dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 20px 0 0;
}

.qs-latest dl div {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
}

.qs-latest dt {
    color: var(--muted);
    font-size: 0.78rem;
}

.qs-latest dd {
    margin: 3px 0 0;
    font-weight: 800;
}

.qs-source {
    position: relative;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.qs-state-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: stretch;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(11, 17, 24, 0.8);
}

.qs-state-panel div {
    min-width: 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
}

.qs-state-panel span {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
}

.qs-state-panel strong {
    display: block;
    margin-top: 3px;
    font-size: 0.95rem;
}

.qs-auto-note {
    grid-column: 1 / -1;
    margin: -2px 2px 0;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.6;
}

#refreshButton {
    min-width: 136px;
    border: 0;
    border-radius: 12px;
    color: #06110e;
    background: linear-gradient(135deg, var(--accent), #a4f0dc);
    font-weight: 900;
    cursor: pointer;
}

#refreshButton:disabled {
    opacity: 0.55;
    cursor: wait;
}

.qs-history-card,
.qs-info-grid article,
.qs-related,
.qs-comments {
    padding: 22px;
}

.qs-event-list {
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.qs-event-list li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.qs-event-title {
    min-width: 0;
    font-weight: 800;
}

.qs-event-meta {
    color: var(--muted);
    font-size: 0.86rem;
}

.qs-event-mark {
    align-self: start;
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
    white-space: nowrap;
}

.qs-event-mark.is-watch {
    color: var(--watch);
    border-color: rgba(245, 197, 107, 0.5);
    background: rgba(245, 197, 107, 0.08);
}

.qs-info-grid article p,
.qs-info-grid article li {
    color: #d1deea;
}

.qs-info-grid ol,
.qs-info-grid ul {
    margin: 14px 0 0;
    padding-left: 1.2em;
}

.qs-related .qs-link-grid,
.qs-return {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.qs-link-grid a,
.qs-return a {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
    text-decoration: none;
}

.qs-link-grid strong,
.qs-link-grid span,
.qs-return strong,
.qs-return span,
.qs-return small {
    display: block;
}

.qs-link-grid span,
.qs-return span,
.qs-return small {
    margin-top: 5px;
    color: var(--muted);
    font-size: 0.85rem;
}

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

.qs-comments {
    background: rgba(17, 25, 34, 0.72);
}

.qs-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    padding: 16px 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.comment-section,
#app-comments {
    color: var(--text);
}

@media (max-width: 880px) {
    .qs-shell {
        width: min(100% - 24px, 680px);
        padding-top: 14px;
    }

    .qs-hero,
    .qs-tile,
    .qs-history-card,
    .qs-info-grid article,
    .qs-related,
    .qs-comments {
        border-radius: 14px;
        padding: 18px;
    }

    .qs-monitor,
    .qs-history-grid,
    .qs-info-grid,
    .qs-related .qs-link-grid,
    .qs-return,
    .qs-state-panel {
        grid-template-columns: 1fr;
    }

    .qs-latest dl {
        grid-template-columns: 1fr;
    }

    #refreshButton {
        min-height: 46px;
    }

    .qs-footer {
        display: block;
    }
}

@media (max-width: 420px) {
    .qs-shell {
        width: calc(100% - 18px);
    }

    .qs-tile-head,
    .qs-section-head {
        display: block;
    }

    .qs-status {
        display: inline-flex;
        margin-top: 10px;
    }

    .qs-event-list li {
        grid-template-columns: 1fr;
    }
}
