:root {
    --brand-green: #01894d;
    --brand-green-hover: #017340;
    --brand-orange: #f39800;
    --brand-orange-hover: #db8900;
    --bg-color: #f8fafb;
    --card-bg: #ffffff;
    --text-main: #2d3748;
    --text-sub: #64748b;
    --border-color: #e2e8f0;
    --border-focus: #01894d;
    --accent-bg: #f0fdf4;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.main-header {
    background-color: var(--brand-green);
    border-bottom: 3px solid var(--brand-orange);
    padding: 12px 0;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.main-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.title-icon {
    width: 28px;
    height: 28px;
}

.brand-logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.btn-home {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 6px 14px;
    border-radius: 6px;
    transition: background 0.2s;
    background: rgba(255, 255, 255, 0.12);
}

.btn-home:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 24px auto 40px;
    padding: 0 24px;
}

/* Accordion Section (Usage & Options) */
.info-section,
.options-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.info-header,
.options-header {
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: #fcfcfd;
    user-select: none;
    transition: background 0.2s;
}

.info-header:hover,
.options-header:hover {
    background: #f8fafc;
}

.info-header h2 {
    font-size: 1.05rem;
    color: var(--brand-green);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.options-title {
    font-size: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.opt-icon {
    width: 20px;
    height: 20px;
    color: var(--brand-orange);
}

.toggle-icon {
    width: 20px;
    height: 20px;
    fill: var(--text-sub);
    transition: transform 0.25s ease;
}

.info-section.collapsed .toggle-icon,
.options-section.collapsed .toggle-icon {
    transform: rotate(-180deg);
}

.info-content,
.options-content {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: block;
    font-size: 0.95rem;
    color: var(--text-main);
}

.info-section.collapsed .info-content,
.options-section.collapsed .options-content {
    display: none;
}

.usage-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin: 16px 0;
}

.usage-step {
    padding-left: 38px;
    position: relative;
    font-size: 0.9rem;
}

.usage-step::before {
    content: attr(data-step);
    position: absolute;
    left: 0;
    top: 0;
    width: 26px;
    height: 26px;
    background: var(--brand-green);
    color: #fff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.step-title {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.step-desc {
    color: var(--text-sub);
    font-size: 0.85rem;
}

.disclaimer {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--brand-orange);
    padding: 12px 16px;
    border-radius: 6px;
    margin-top: 12px;
    font-size: 0.85rem;
}

.disclaimer-title {
    font-weight: 700;
    color: var(--text-main);
    margin-top: 6px;
    margin-bottom: 2px;
}

.disclaimer-title:first-child {
    margin-top: 0;
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.opt-group {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.opt-group-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--brand-green);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e2e8f0;
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 10px;
    user-select: none;
}

.checkbox-label:last-child,
.radio-label:last-child {
    margin-bottom: 0;
}

.checkbox-label input,
.radio-label input {
    cursor: pointer;
    accent-color: var(--brand-green);
    width: 16px;
    height: 16px;
}

.opt-subitem {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.opt-sublabel {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-sub);
    min-width: 110px;
}

/* Main Converter Layout (Grid) */
.converter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Card & Panels */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.panel-header {
    background: #fcfcfd;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Tabs */
.tab-group {
    display: flex;
    gap: 6px;
    background: #edf2f7;
    padding: 3px;
    border-radius: 8px;
}

.tab-btn {
    border: none;
    background: transparent;
    color: var(--text-sub);
    padding: 7px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    background: #ffffff;
    color: var(--brand-green);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Actions in Panel Header */
.panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-sub {
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-main);
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-sub:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.file-btn-label {
    cursor: pointer;
    user-select: none;
}

.btn-danger {
    color: #e53e3e;
    border-color: #feb2b2;
}

.btn-danger:hover {
    background: #fff5f5;
    border-color: #fc8181;
}

.btn-action {
    border: none;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}

.action-svg {
    width: 16px;
    height: 16px;
}

.btn-copy {
    background: var(--brand-green);
    color: #ffffff;
}

.btn-copy:hover {
    background: var(--brand-green-hover);
}

.btn-download {
    background: var(--brand-orange);
    color: #ffffff;
}

.btn-download:hover {
    background: var(--brand-orange-hover);
}

/* Editors & Preview Area */
.editor-wrapper {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    min-height: 540px;
    background: #ffffff;
}

.text-editor {
    width: 100%;
    height: 100%;
    min-height: 540px;
    max-height: 700px;
    overflow-y: auto;
    border: none;
    padding: 16px;
    font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #1a202c;
    background: #ffffff;
    resize: none;
    outline: none;
    box-sizing: border-box;
    tab-size: 2;
}

.text-editor:focus {
    background: #fafcfb;
}

/* Preview Box Typography */
.preview-container {
    width: 100%;
    height: 100%;
    min-height: 540px;
    max-height: 700px;
    overflow-y: auto;
    padding: 24px;
    box-sizing: border-box;
    font-family: 'Noto Sans JP', 'Inter', sans-serif;
    color: #2d3748;
    line-height: 1.75;
    background: #ffffff;
    word-break: break-word;
}

.preview-container:empty::before {
    content: "入力テキストのプレビューがここに表示されます...";
    color: #a0aec0;
    font-style: italic;
}

/* Markdown / HTML Elements within Preview */
.preview-container h1,
.preview-container h2,
.preview-container h3,
.preview-container h4,
.preview-container h5,
.preview-container h6 {
    color: #1a202c;
    font-weight: 700;
    margin-top: 1.4em;
    margin-bottom: 0.6em;
    line-height: 1.35;
}

.preview-container h1:first-child,
.preview-container h2:first-child,
.preview-container h3:first-child {
    margin-top: 0;
}

.preview-container h1 {
    font-size: 1.65rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.3em;
}

.preview-container h2 {
    font-size: 1.35rem;
    border-bottom: 1px solid #edf2f7;
    padding-bottom: 0.25em;
    border-left: 4px solid var(--brand-green);
    padding-left: 10px;
}

.preview-container h3 {
    font-size: 1.15rem;
}

.preview-container h4 {
    font-size: 1rem;
}

.preview-container p {
    margin-bottom: 1em;
}

.preview-container a {
    color: var(--brand-green);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.preview-container a:hover {
    color: var(--brand-green-hover);
}

.preview-container ul,
.preview-container ol {
    margin-bottom: 1.1em;
    padding-left: 1.8em;
}

.preview-container li {
    margin-bottom: 0.35em;
}

.preview-container li input[type="checkbox"] {
    margin-right: 0.5em;
}

.preview-container blockquote {
    margin: 1.2em 0;
    padding: 10px 16px;
    color: #4a5568;
    background-color: #f7fafc;
    border-left: 4px solid var(--brand-green);
    border-radius: 0 6px 6px 0;
}

.preview-container blockquote > :last-child {
    margin-bottom: 0;
}

.preview-container code {
    font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
    font-size: 0.88em;
    background: #edf2f7;
    color: #c53030;
    padding: 2px 6px;
    border-radius: 4px;
}

.preview-container pre {
    background: #1a202c;
    color: #f7fafc;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.2em 0;
}

.preview-container pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: 0.9em;
}

.preview-container table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
    font-size: 0.92rem;
}

.preview-container th,
.preview-container td {
    border: 1px solid #cbd5e1;
    padding: 8px 12px;
    text-align: left;
}

.preview-container th {
    background: #f1f5f9;
    font-weight: 700;
    color: #1e293b;
}

.preview-container tr:nth-child(even) td {
    background: #f8fafc;
}

.preview-container hr {
    border: none;
    border-top: 2px solid #e2e8f0;
    margin: 1.8em 0;
}

.preview-container img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 0.8em 0;
}

/* Panel Footer */
.panel-footer {
    background: #fcfcfd;
    border-top: 1px solid var(--border-color);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-sub);
}

.counter-group {
    display: flex;
    gap: 16px;
}

.counter-item strong {
    color: var(--text-main);
    font-weight: 700;
}

.helper-text {
    font-size: 0.8rem;
    color: #94a3b8;
}

.output-status {
    font-size: 0.8rem;
    color: var(--brand-green);
    font-weight: 600;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(30, 41, 59, 0.94);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 9999;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 1024px) {
    .converter-grid {
        grid-template-columns: 1fr;
    }

    .editor-wrapper {
        min-height: 420px;
    }

    .text-editor,
    .preview-container {
        min-height: 420px;
        max-height: 520px;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .container {
        margin: 16px auto 30px;
        padding: 0 14px;
    }

    .brand-logo {
        font-size: 1.05rem;
    }

    .panel-header {
        flex-direction: column;
        align-items: stretch;
    }

    .tab-group {
        width: 100%;
        justify-content: stretch;
    }

    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 6px 8px;
        font-size: 0.85rem;
    }

    .panel-actions {
        justify-content: flex-end;
    }

    .panel-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}
