/* ── Base ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', 'Meiryo UI', 'Meiryo', 'Yu Gothic UI', sans-serif;
    background: #f5f5f5;
    margin: 0;
    padding: 32px 16px 60px;
    color: #333;
    font-size: 14px;
}

.container {
    max-width: 560px;
    margin: 0 auto;
}

/* ── Page header ────────────────────────────────────────────── */
.page-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 20px;
    background: #fff;
    border-radius: 12px 12px 0 0;
    margin-top: 0;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #222;
    margin: 0 0 4px;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.subtitle {
    font-size: 13px;
    color: #777;
    margin: 0;
}

/* ── Source toggle ──────────────────────────────────────────── */
.source-toggle {
    display: flex;
    gap: 24px;
    align-items: center;
    padding: 14px 20px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: #555;
    cursor: pointer;
}

/* ── Section cards ──────────────────────────────────────────── */
.section-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 18px 20px 20px;
    margin-top: 14px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #888;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    color: #222;
}

/* ── Choice button groups ───────────────────────────────────── */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.choice-btn {
    padding: 9px 20px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.choice-btn:hover {
    background: #f0f0f0;
    border-color: #aaa;
}

.choice-btn.active {
    background: #666;
    color: #fff;
    border-color: #555;
}

/* ── Lesson / unit field ────────────────────────────────────── */
.field-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.field-label {
    font-size: 13px;
    color: #555;
    white-space: nowrap;
}

.select-wrapper {
    flex: 1;
}

.field-input {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #333;
    outline: none;
}

.field-input:focus {
    border-color: #888;
}

.lesson-select {
    appearance: auto;
    cursor: pointer;
}

.lesson-select:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* ── URL section ────────────────────────────────────────────── */
.url-section {
    margin-top: 4px;
}

.url-section-label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.url-hint {
    font-size: 12px;
    color: #888;
    margin-bottom: 10px;
    line-height: 1.5;
}

.url-field-row {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #ccc;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.url-prefix {
    padding: 0 10px;
    font-size: 13px;
    color: #555;
    white-space: nowrap;
    background: #f7f7f7;
    border-right: 1px solid #ccc;
    height: 38px;
    display: flex;
    align-items: center;
}

.url_input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0 10px;
    font-size: 13px;
    font-family: inherit;
    color: #555;
    background: #fff;
    height: 38px;
    min-width: 0;
}

.edit-btn {
    padding: 0 14px;
    height: 38px;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    background: #f0f0f0;
    border: none;
    border-left: 1px solid #ccc;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.edit-btn:hover {
    background: #e4e4e4;
}

/* ── Recording section ──────────────────────────────────────── */
.recording-preview {
    font-size: 12px;
    color: #555;
    background: #f7f7f7;
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 8px;
}

/* ── Run summary ────────────────────────────────────────────── */
.run-summary {
    font-size: 14px;
    color: #444;
    line-height: 1.9;
}

.run-summary-title {
    color: #333;
    margin-bottom: 2px;
}

.run-summary-item {
    color: #444;
}

/* ── Field errors ───────────────────────────────────────────── */
.field-errors {
    color: #d00;
    font-size: 13px;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff5f5;
    border: 1px solid #fcc;
    border-radius: 6px;
}

/* ── Submit button ──────────────────────────────────────────── */
.submit-btn {
    display: block;
    width: 100%;
    margin-top: 18px;
    padding: 16px;
    font-size: 17px;
    font-family: inherit;
    font-weight: 700;
    background: #888;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: background 0.15s;
}

.submit-btn:hover {
    background: #666;
}

.submit-btn:disabled {
    background: #bbb;
    cursor: not-allowed;
}

/* ── Generic btn (log panel, etc.) ─────────────────────────── */
.btn {
    padding: 7px 14px;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: background 0.12s;
}

.btn:hover {
    background: #f0f0f0;
}

/* ── Result / status ────────────────────────────────────────── */
.result {
    margin-top: 16px;
    font-size: 14px;
    min-height: 20px;
}

.loading {
    color: #555;
}

/* ── Report iframe ──────────────────────────────────────────── */
iframe {
    width: 100%;
    height: 600px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

/* ── Wide log mode ──────────────────────────────────────────── */
.wide-log {
    width: 100vw !important;
    max-width: none !important;
    margin-left: calc(50% - 50vw) !important;
    box-sizing: border-box;
    padding-left: 20px;
    padding-right: 20px;
    border-left: 0;
    border-right: 0;
}

/* ── Slide panels ───────────────────────────────────────────── */
.slide-panel {
    transition: max-height 220ms ease, opacity 200ms ease, margin 200ms ease;
    overflow: hidden;
    max-height: 1000px;
    opacity: 1;
}

.slide-hidden {
    max-height: 0 !important;
    opacity: 0 !important;
    margin-top: 0 !important;
}

.slide-visible {
    max-height: 500px !important;
    opacity: 1 !important;
}

#recordingControls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}

#recordingControls label {
    width: 100%;
}

#recordingPreview {
    display: block;
    margin-top: 6px;
}

/* ── Jobs list ──────────────────────────────────────────────── */
#jobsList {
    margin-top: 20px;
    max-height: 360px;
    overflow: auto;
    border: 1px solid #e6e6e6;
    padding: 8px;
    border-radius: 6px;
    background: #fafafa;
}

#jobsList details {
    margin-bottom: 8px;
}

#jobsList .btn {
    margin-right: 6px;
}

/* ── Scenario Panel ─────────────────────────────────────────── */
.scenario-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
    transition: box-shadow 0.2s;
}

.scenario-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.scenario-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
}

.scenario-header .expand-icon {
    font-size: 12px;
    color: #666;
    transition: transform 0.2s;
    min-width: 16px;
}

.scenario-item.expanded .scenario-header .expand-icon {
    transform: rotate(90deg);
}

.subject-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    color: #fff;
}

.subject-badge.kokugo {
    background: #4a90d9;
}

.subject-badge.sansuu {
    background: #e67e22;
}

.subject-badge.rika {
    background: #27ae60;
}

.subject-badge.shakai {
    background: #8e44ad;
}

.subject-badge.kanji {
    background: #c0392b;
}

.subject-badge.keisan {
    background: #16a085;
}

.scenario-lesson {
    flex: 1;
    font-size: 0.95em;
    color: #333;
}

.scenario-info {
    font-size: 0.85em;
    color: #888;
}

.scenario-date {
    font-size: 0.85em;
    color: #999;
    white-space: nowrap;
}

.scenario-steps {
    display: none;
    padding: 0 16px 12px 16px;
    border-top: 1px solid #f0f0f0;
}

.scenario-item.expanded .scenario-steps {
    display: block;
}

.step-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 0.9em;
}

.step-row:last-child {
    border-bottom: none;
}

.step-type {
    display: inline-block;
    min-width: 60px;
    font-size: 0.85em;
    color: #666;
    font-family: monospace;
}

.step-desc {
    flex: 1;
    color: #444;
}

.step-value-edit {
    width: 200px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9em;
}

.step-value-edit:focus {
    border-color: #4a90d9;
    outline: none;
}

.scenario-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.btn-execute {
    background: #27ae60;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
}

.btn-execute:hover {
    background: #219a52;
}

.btn-execute:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.btn-stop {
    background: #e74c3c;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    display: none;
}

.btn-stop:hover {
    background: #c0392b;
}

.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.pagination button {
    min-width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 0.9em;
}

.pagination button.active {
    background: #666;
    color: #fff;
    border-color: #555;
}

.pagination button:hover:not(.active) {
    background: #f0f0f0;
}
