:root {
    --primary-color: #0f172a; /* Slate 900 */
    --accent-color: #3b82f6; /* Blue 500 */
    --bg-color: #f1f5f9; /* Slate 100 */
    --surface-color: #ffffff;
    --text-primary: #334155; /* Slate 700 */
    --text-secondary: #64748b; /* Slate 500 */
    --border-color: #e2e8f0; /* Slate 200 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 2rem;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

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

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.header-left h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
    letter-spacing: -0.025em;
}

.header-left p {
    margin: 0;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-right {
    padding-top: 0.5rem;
}

.github-link {
    color: var(--text-primary);
    transition: color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
}

.github-link:hover {
    color: var(--accent-color);
    transform: translateY(-2px);
}

.github-link svg {
    fill: currentColor;
}

/* Usage Guide */
.usage-guide {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    color: #1e3a8a;
}

.usage-guide h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.usage-guide ul {
    margin: 0;
    padding-left: 1.5rem;
    font-size: 0.95rem;
}

.usage-guide li {
    margin-bottom: 0.25rem;
}

.usage-guide code {
    background: #ffffff;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-weight: 500;
    color: var(--accent-color);
    border: 1px solid #bfdbfe;
}

/* Common Card Styles */
.input-area,
.preview-area,
.comparison-area,
.code-output-area {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2.5rem;
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s;
}

.input-area:hover,
.preview-area:hover,
.comparison-area:hover {
    box-shadow: var(--shadow-md);
}

h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    border-left: 4px solid var(--accent-color);
    padding-left: 1rem;
    line-height: 1.25;
}

/* Controls (Slider) */
.controls {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    border: 1px solid var(--border-color);
}

.controls label {
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

#width-value {
    font-family: 'Roboto Mono', monospace;
    font-weight: 500;
    color: var(--accent-color);
    min-width: 60px;
    text-align: right;
}

input[type="range"] {
    flex-grow: 1;
    cursor: pointer;
    accent-color: var(--accent-color);
}

/* Workspace */
.workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

/* Textarea */
textarea {
    width: 100%;
    height: 320px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: 'Noto Sans JP', sans-serif;
    line-height: 1.8;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #f8fafc;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background-color: #fff;
}

/* Preview Box */
.preview-box {
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: var(--radius-md);
    background: #fff;
    margin-left: auto;
    margin-right: auto;
    width: fit-content;
    box-shadow: var(--shadow-sm); /* Inner card feel */
    
    /* Container Queries */
    container-type: inline-size;
    container-name: preview;
}

#normal-preview-container {
    border-color: #cbd5e1;
    background-color: #f8fafc;
}

/* Budoux styles */
budoux-ja {
    display: block;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

/* Device Preview Area */
.device-preview-area {
    margin-top: 4rem;
}

.device-preview-area h2 {
    margin-bottom: 2rem;
}

.devices-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center; /* Center them for a nice showcase */
    align-items: flex-start;
    padding-bottom: 1rem;
}

/* Device Frames */
.device-frame {
    background: var(--surface-color);
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}

.device-frame:hover {
    transform: translateY(-4px);
}

.device-header {
    background: #f1f5f9;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-header label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.width-input {
    width: 70px;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: right;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: #fff;
}

.width-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.device-content {
    background: #fff;
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 600px;
    font-size: 0.95rem;
}

/* Detailed Device Specs */
.device-frame.mobile { width: 375px; flex-shrink: 0; }
.device-frame.tablet { width: 768px; flex-shrink: 0; }
.device-frame.desktop { width: 1024px; flex-shrink: 0; max-width: 100%; }

/* Code Output Area */
.code-output-area p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

#output-html {
    background-color: #1e293b; /* Dark terminal bg */
    color: #e2e8f0;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: none;
    height: 150px;
}

/* Device Specific Break Logic (Keep logic, update nothing visual) */
.sp-br, .pc-br { display: none; }

@media (max-width: 767.9px) {
    .device-frame.mobile .sp-br { display: inline; }
    .device-frame.mobile .sp-br::before { content: "\A"; white-space: pre; }
    .device-frame.mobile .pc-br { display: none; }
}

@media (min-width: 768px) {
    .device-frame.tablet .pc-br, .device-frame.desktop .pc-br { display: inline; }
    .device-frame.tablet .pc-br::before, .device-frame.desktop .pc-br::before { content: "\A"; white-space: pre; }
    .device-frame.tablet .sp-br, .device-frame.desktop .sp-br { display: none; }
}

@container preview (max-width: 767.9px) {
    .sp-br { display: inline; }
    .sp-br::before { content: "\A"; white-space: pre; }
    .pc-br { display: none; }
}

@container preview (min-width: 768px) {
    .pc-br { display: inline; }
    .pc-br::before { content: "\A"; white-space: pre; }
    .sp-br { display: none; }
}

/* Responsive Main Layout */
@media (max-width: 1100px) {
    .device-frame.desktop { width: 100%; }
}
