* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
    background: #ffffff;
    color: #37352f;
    line-height: 1.5;
    padding: 20px;
}

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

header {
    margin-bottom: 16px;
}

h1 {
    font-size: 28px;
    font-weight: 700;
    color: #37352f;
}

/* タブナビゲーション */
.tab-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid #e9e9e7;
    padding-bottom: 0;
}

.tab-button {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 15px;
    font-weight: 500;
    color: #9b9a97;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    bottom: -2px;
}

.tab-button:hover {
    color: #37352f;
    background: #f7f6f3;
}

.tab-button.active {
    color: #2383e2;
    border-bottom-color: #2383e2;
}

/* タブコンテンツ */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

h2 {
    font-size: 18px;
    font-weight: 600;
    color: #37352f;
}

h3 {
    font-size: 14px;
    font-weight: 600;
    color: #37352f;
}

.top-sections {
    display: flex;
    flex-direction: row;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
}

/* プレビューセクション */
.preview-section {
    background: #ffffff;
    border: 1px solid #e9e9e7;
    border-radius: 8px;
    padding: 20px;
    flex: 1;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    min-width: 0;
}

.url-input-group {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 300px;
}

.url-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e9e9e7;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.15s ease;
}

.url-input:focus {
    outline: none;
    border-color: #2383e2;
    box-shadow: 0 0 0 2px rgba(35, 131, 226, 0.1);
}

.preview-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #f7f6f3;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#previewFrame,
#discordPreviewFrame {
    width: 100%;
    height: 100%;
    display: none;
    border: none;
}

#previewFrame.loaded,
#discordPreviewFrame.loaded {
    display: block;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9b9a97;
    gap: 12px;
}

.preview-placeholder.hidden {
    display: none;
}

/* CSS生成セクション */
.generator-section {
    background: #ffffff;
    border: 1px solid #e9e9e7;
    border-radius: 8px;
    padding: 20px;
    flex: 0 0 300px;
    max-width: 300px;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.control-group label {
    font-size: 13px;
    font-weight: 500;
    color: #37352f;
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-group input[type="number"],
.control-group input[type="text"],
.control-group input[type="color"],
.control-group select,
.control-group textarea {
    padding: 8px 12px;
    border: 1px solid #e9e9e7;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.15s ease;
}

.control-group input[type="color"] {
    padding: 4px;
    height: 40px;
    cursor: pointer;
}

.control-group select {
    background: white;
    cursor: pointer;
}

.control-group input[type="number"]:focus,
.control-group input[type="text"]:focus,
.control-group input[type="color"]:focus,
.control-group select:focus,
.control-group textarea:focus {
    outline: none;
    border-color: #2383e2;
    box-shadow: 0 0 0 2px rgba(35, 131, 226, 0.1);
}

.control-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.control-group textarea {
    resize: vertical;
    min-height: 60px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 13px;
}

/* 要素オプション */
.element-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    grid-column: 1 / -1;
    padding: 16px;
    background: #f7f6f3;
    border-radius: 6px;
    margin-top: 8px;
}

.element-options:empty {
    display: none;
}

/* オプション行（複数の項目を横並びに配置） */
.option-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

/* ボタン */
.btn-primary,
.btn-secondary {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary {
    background: #2383e2;
    color: white;
}

.btn-primary:hover {
    background: #1a6fc4;
}

.btn-secondary {
    background: #f7f6f3;
    color: #37352f;
    border: 1px solid #e9e9e7;
}

.btn-secondary:hover {
    background: #efeeeb;
}

/* 出力セクション */
.output-section {
    background: #ffffff;
    border: 1px solid #e9e9e7;
    border-radius: 8px;
    padding: 20px;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.css-output {
    background: #f7f6f3;
    border: 1px solid #e9e9e7;
    border-radius: 6px;
    padding: 16px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #37352f;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* レスポンシブ */
@media (max-width: 1024px) {
    .top-sections {
        flex-direction: column;
    }

    .preview-section {
        flex: 1;
        position: static;
        max-height: none;
    }

    .generator-section {
        flex: 1;
        max-width: none;
    }
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    h1 {
        font-size: 24px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .url-input-group {
        width: 100%;
        min-width: 0;
    }

    .preview-container {
        aspect-ratio: 16 / 9;
    }

    .controls {
        grid-template-columns: 1fr;
    }
}
