* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: #202124;
    background: #f6f7f9;
}

.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px;
}

.page.wide {
    max-width: 1680px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
}

h1 {
    margin: 0 0 4px;
    font-size: 28px;
}

p {
    margin: 0;
}

button {
    border: 1px solid #155e75;
    background: #155e75;
    color: white;
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}

button:disabled {
    opacity: 0.65;
    cursor: wait;
}

button:hover,
.button:hover {
    background: #0e7490;
}

.button {
    display: inline-block;
    border: 1px solid #155e75;
    background: #155e75;
    color: white;
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}

button.secondary,
.button.secondary {
    border-color: #64748b;
    background: #64748b;
}

.button.disabled {
    border-color: #cbd5e1;
    background: #e2e8f0;
    color: #64748b;
    cursor: default;
}

.top-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

button.danger {
    border-color: #9f1239;
    background: #9f1239;
}

.calendar {
    display: grid;
    gap: 12px;
}

.week-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.week-calendar {
    display: grid;
    grid-template-columns: 72px repeat(7, minmax(170px, 1fr));
    overflow-x: auto;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.calendar-head,
.hour-label,
.hour-cell {
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

.calendar-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    gap: 2px;
    min-height: 52px;
    padding: 10px;
    background: #f8fafc;
}

.calendar-head span {
    color: #64748b;
    font-size: 13px;
}

.time-head {
    left: 0;
    z-index: 3;
}

.hour-label {
    position: sticky;
    left: 0;
    z-index: 1;
    padding: 10px 8px;
    background: #f8fafc;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
}

.hour-cell {
    min-height: 104px;
    padding: 6px;
    background: #ffffff;
}

.hour-cell.locked {
    background: #f1f5f9;
}

.locked-note {
    margin-top: 4px;
    color: #94a3b8;
    font-size: 12px;
    text-align: center;
}

.mini-post {
    display: grid;
    gap: 6px;
    margin-bottom: 6px;
    padding: 8px;
    border-left: 4px solid #94a3b8;
    border-radius: 6px;
    background: #f8fafc;
}

.mini-post.status-approved,
.mini-post.status-ready {
    border-left-color: #16a34a;
}

.mini-post.status-published {
    border-left-color: #155e75;
    opacity: 0.78;
}

.mini-post.status-failed {
    border-left-color: #dc2626;
}

.mini-post-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: #475569;
    font-size: 11px;
    text-transform: uppercase;
}

.mini-post p {
    font-size: 13px;
    line-height: 1.3;
}

.mini-post-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.mini-flag,
.mini-image-link,
.mini-more {
    display: inline-flex;
    align-items: center;
    min-height: 17px;
    padding: 1px 5px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
}

.mini-flag.post-ok {
    background: #dcfce7;
    color: #166534;
}

.mini-flag.post-missing {
    background: #f1f5f9;
    color: #64748b;
}

.mini-flag.image-count {
    background: #eef2ff;
    color: #3730a3;
}

.mini-image-link {
    background: #e0f2fe;
    color: #075985;
}

.mini-more {
    background: #f8fafc;
    color: #475569;
}

.mini-post-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mini-post-actions a {
    color: #155e75;
    font-size: 13px;
    font-weight: 700;
}

.mini-post-actions button,
.add-candidate button {
    min-width: 30px;
    padding: 5px 7px;
    font-size: 12px;
}

.add-candidate {
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

.slot {
    display: grid;
    grid-template-columns: 130px 1fr auto;
    gap: 16px;
    padding: 16px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.slot-time span,
.meta {
    display: block;
    margin-top: 6px;
    color: #65605a;
    font-size: 13px;
}

.saying {
    margin-bottom: 8px;
    font-size: 18px;
    line-height: 1.35;
}

details {
    margin-top: 8px;
    color: #4b5563;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    align-content: start;
}

.empty {
    padding: 24px;
    border: 1px dashed #9ca3af;
    border-radius: 8px;
    background: #ffffff;
}

.footer-link {
    margin-top: 12px;
}

.legal-page {
    max-width: 920px;
}

.legal-section {
    margin-bottom: 14px;
    padding: 18px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.legal-section h2 {
    margin: 0 0 10px;
    font-size: 19px;
}

.legal-section p {
    margin-bottom: 10px;
    line-height: 1.55;
}

.legal-section p:last-child {
    margin-bottom: 0;
}

.notice {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #d7dde5;
}

.notice.success {
    border-color: #16a34a;
    color: #14532d;
}

.notice.error {
    border-color: #dc2626;
    color: #7f1d1d;
}

.publish-state {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 14px;
    align-items: center;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid #d7dde5;
    border-left: 5px solid #f59e0b;
    border-radius: 8px;
    background: #ffffff;
}

.publish-state.success {
    border-left-color: #16a34a;
}

.publish-state.error {
    border-left-color: #dc2626;
}

.publish-state h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.publish-state p {
    color: #475569;
}

.publish-state .error-text {
    color: #7f1d1d;
}

.publish-state-meta {
    display: grid;
    gap: 4px;
    color: #64748b;
    font-size: 13px;
}

.settings-form {
    display: grid;
    gap: 18px;
}

.settings-section {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
    padding: 18px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.settings-section h2 {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 18px;
}

label {
    display: grid;
    gap: 6px;
    color: #374151;
    font-size: 14px;
}

input {
    width: 100%;
    min-height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    background: #ffffff;
}

textarea,
select {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    background: #ffffff;
}

textarea {
    resize: vertical;
}

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

.detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-top: 18px;
}

.provider-generate {
    display: grid;
    gap: 12px;
    margin-top: 18px;
    padding: 16px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.upload-image-form {
    display: grid;
    gap: 12px;
    margin-top: 18px;
    padding: 16px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.upload-image-form p {
    margin-top: 4px;
    color: #64748b;
    font-size: 14px;
}

.replace-image-form {
    display: grid;
    gap: 8px;
}

.replace-image-form input[type="file"],
.upload-image-form input[type="file"] {
    padding: 7px;
}

.provider-generate p {
    margin-top: 4px;
    color: #64748b;
    font-size: 14px;
}

.prompt-tabs {
    display: grid;
    gap: 12px;
}

.prompt-tabs h3 {
    margin: 0;
    font-size: 17px;
}

.prompt-tabs p {
    color: #64748b;
    font-size: 14px;
}

.provider-choice {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 7px;
    width: auto;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    cursor: pointer;
}

.radio-label input {
    width: auto;
    min-height: auto;
}

.provider-checkbox {
    width: auto;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
}

.prompt-panel {
    display: none;
}

.prompt-panel.active {
    display: grid;
}

.image-variants {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.image-variants h2 {
    margin: 0;
    font-size: 20px;
}

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

.variant-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.variant-card.selected {
    border-color: #16a34a;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.14);
}

.variant-preview {
    display: grid;
    place-items: center;
    min-height: 150px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #475569;
    font-weight: 700;
}

.variant-preview img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
}

.variant-meta {
    display: grid;
    gap: 3px;
}

.variant-meta span {
    color: #64748b;
    font-size: 13px;
}

.selected-label {
    color: #14532d;
    font-weight: 700;
}

.secret-status {
    width: fit-content;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.secret-status.set {
    background: #ecfdf5;
    color: #166534;
}

.secret-status.missing {
    background: #fff7ed;
    color: #c2410c;
}

.log-section {
    display: grid;
    gap: 12px;
    margin-bottom: 22px;
}

.log-section h2 {
    margin: 0;
    font-size: 20px;
}

.log-list {
    display: grid;
    gap: 10px;
}

.log-row {
    display: grid;
    grid-template-columns: 210px 1fr 280px;
    gap: 14px;
    align-items: start;
    padding: 14px;
    border: 1px solid #d7dde5;
    border-left: 5px solid #94a3b8;
    border-radius: 8px;
    background: #ffffff;
}

.log-row.success {
    border-left-color: #16a34a;
}

.log-row.error {
    border-left-color: #dc2626;
}

.log-row.pending {
    border-left-color: #f59e0b;
}

.queue-list {
    display: grid;
    gap: 10px;
}

.article-queue {
    margin-top: 22px;
}

.queue-list h2 {
    margin: 0;
    font-size: 20px;
}

.queue-row {
    display: grid;
    grid-template-columns: 170px 1fr 260px 180px;
    gap: 14px;
    align-items: start;
    padding: 14px;
    border: 1px solid #d7dde5;
    border-left: 5px solid #94a3b8;
    border-radius: 8px;
    background: #ffffff;
}

.queue-row.success {
    border-left-color: #16a34a;
}

.queue-row.error {
    border-left-color: #dc2626;
}

.queue-row.pending {
    border-left-color: #f59e0b;
}

.queue-row span {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 13px;
}

.queue-actions {
    display: grid;
    gap: 8px;
}

.ranking-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.rank-card {
    display: grid;
    gap: 6px;
    min-height: 86px;
    padding: 16px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.rank-card span {
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.rank-card strong {
    font-size: 24px;
    line-height: 1.1;
}

.ranking-panel {
    display: grid;
    gap: 12px;
    margin-bottom: 22px;
}

.ranking-panel h2 {
    margin: 0;
    font-size: 20px;
}

.ranking-learning {
    padding: 14px 16px;
    border: 1px solid #bbf7d0;
    border-left: 5px solid #2f7d57;
    border-radius: 8px;
    background: #f0fdf4;
}

.ranking-learning p {
    max-width: 980px;
    margin: 0;
    color: #365346;
    line-height: 1.55;
}

.ranking-table {
    display: grid;
    grid-template-columns: minmax(220px, 1.6fr) repeat(5, minmax(90px, 0.7fr));
    overflow-x: auto;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.ranking-head,
.ranking-cell {
    min-height: 42px;
    padding: 10px 12px;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

.ranking-head {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.ranking-cell {
    color: #202124;
    font-size: 14px;
}

.ranking-cell.category-name {
    color: #155e75;
    text-decoration: none;
}

.ranking-post-list {
    display: grid;
    gap: 10px;
}

.ranking-post {
    display: grid;
    grid-template-columns: 92px 1fr 180px 150px;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border: 1px solid #d7dde5;
    border-left: 5px solid #155e75;
    border-radius: 8px;
    background: #ffffff;
}

.ranking-score {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 8px;
    border-radius: 8px;
    background: #eef2ff;
    color: #3730a3;
}

.ranking-score strong {
    font-size: 24px;
    line-height: 1;
}

.ranking-score span,
.ranking-post-meta,
.ranking-metrics span {
    color: #64748b;
    font-size: 12px;
}

.ranking-post p {
    margin-top: 5px;
    line-height: 1.35;
}

.ranking-post-meta,
.ranking-metrics {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ranking-metrics {
    display: grid;
}

.ranking-metrics strong {
    color: #202124;
}

.inline-form {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
}

.inline-form label {
    min-width: 260px;
}

.account-list,
.inspiration-list {
    display: grid;
    gap: 10px;
}

.account-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.account-row form:first-child {
    display: grid;
    grid-template-columns: minmax(220px, .8fr) 110px minmax(240px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.checkbox-label.compact {
    min-height: 42px;
    align-content: center;
}

.account-meta {
    display: grid;
    gap: 4px;
    color: #64748b;
    font-size: 13px;
}

.inspiration-row {
    display: grid;
    grid-template-columns: 190px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border: 1px solid #d7dde5;
    border-left: 5px solid #2f7d57;
    border-radius: 8px;
    background: #ffffff;
}

.inspiration-row span {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 13px;
}

.muted {
    color: #64748b;
    margin-top: 0;
}

.content-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
}

.content-form .full-row {
    grid-column: 1 / -1;
}

.content-list {
    display: grid;
    gap: 12px;
}

.topic-list {
    display: grid;
    gap: 10px;
}

.topic-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.topic-row .inline-form {
    align-items: center;
}

.content-row,
.source-row {
    display: grid;
    gap: 12px;
    align-items: start;
    padding: 14px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.content-row {
    grid-template-columns: 1fr auto auto;
}

.content-row:target {
    border-color: #155e75;
    box-shadow: 0 0 0 3px rgba(21, 94, 117, 0.16);
}

.source-row {
    grid-template-columns: 1fr auto auto auto;
}

.content-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    color: #64748b;
    font-size: 13px;
}

.log-row span {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 13px;
}

.log-context {
    margin-top: 8px;
}

.log-context summary {
    cursor: pointer;
    color: #155e75;
    font-size: 13px;
}

.log-context pre {
    max-width: 100%;
    overflow: auto;
    margin: 8px 0 0;
    padding: 10px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #334155;
    font-size: 12px;
    line-height: 1.4;
}

.error-text {
    color: #7f1d1d;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-label input {
    width: auto;
    min-height: auto;
}

.settings-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.52);
}

.modal-overlay[hidden] {
    display: none;
}

.modal-box {
    width: min(880px, 100%);
    max-height: min(760px, calc(100vh - 48px));
    overflow: auto;
    padding: 20px;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.modal-header h2 {
    margin-top: 0;
}

.modal-header p {
    color: #64748b;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-color: #cbd5e1;
    background: #ffffff;
    color: #334155;
    font-size: 22px;
    line-height: 1;
}

.icon-button:hover {
    background: #f1f5f9;
}

.source-html-form {
    display: grid;
    gap: 14px;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.46);
}

.loading-overlay[hidden] {
    display: none;
}

.loading-box {
    display: grid;
    justify-items: center;
    gap: 12px;
    width: min(360px, 100%);
    padding: 24px;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
    text-align: center;
}

.loading-box strong {
    font-size: 18px;
}

.loading-box p {
    color: #475569;
    line-height: 1.45;
}

.loading-spinner {
    width: 34px;
    height: 34px;
    border: 4px solid #cbd5e1;
    border-top-color: #155e75;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

body.is-loading {
    cursor: wait;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 840px) {
    .topbar,
    .slot,
    .settings-section,
    .publish-state,
    .log-row,
    .queue-row,
    .ranking-summary,
    .ranking-post,
    .account-row,
    .account-row form:first-child,
    .inspiration-row,
    .content-form,
    .content-row,
    .source-row,
    .topic-row {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
    }

    .actions {
        justify-content: flex-start;
    }
}
