@import url('https://fonts.googleapis.com/css2?family=Zen+Kaku+Gothic+New:wght@400;500;700&family=Shippori+Mincho:wght@400;600;700&display=swap');

:root {
    /* Washi Paper Palette */
    --bg-primary: #faf8f5;
    --bg-secondary: #f5f2ed;
    --bg-card: #ffffff;
    --bg-input: #fefdfb;

    /* Ink Colors */
    --ink-primary: #2d2a26;
    --ink-secondary: #5c574f;
    --ink-muted: #8a847a;
    --ink-light: #b8b2a6;

    /* Accent - Shu (Vermillion) */
    --accent: #c73e3a;
    --accent-soft: #e8a5a3;
    --accent-bg: #fef5f5;

    /* Functional */
    --success: #4a7c59;
    --border: #e5e0d8;
    --border-strong: #d4cec4;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(45, 42, 38, 0.04);
    --shadow-md: 0 4px 12px rgba(45, 42, 38, 0.06);
    --shadow-lg: 0 8px 32px rgba(45, 42, 38, 0.08);
    --shadow-float: 0 12px 48px rgba(45, 42, 38, 0.12);

    /* Typography */
    --font-display: 'Shippori Mincho', 'Yu Mincho', serif;
    --font-body: 'Zen Kaku Gothic New', 'Hiragino Sans', sans-serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--ink-primary);
    min-height: 100vh;
    line-height: 1.8;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* Paper texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.025;
    pointer-events: none;
    z-index: 1000;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    position: relative;
}

/* ===== HEADER ===== */
header {
    text-align: center;
    margin-bottom: var(--space-3xl);
    padding: var(--space-2xl) 0;
    position: relative;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 24px;
    background: var(--ink-light);
}

header h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 600;
    color: var(--ink-primary);
    letter-spacing: 0.08em;
    margin-bottom: var(--space-sm);
    position: relative;
    display: inline-block;
}

header h1::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: var(--accent);
}

.subtitle {
    font-family: var(--font-body);
    color: var(--ink-muted);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.12em;
    margin-top: var(--space-lg);
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-md);
    flex-wrap: wrap;
}

.feedback-link {
    display: inline-block;
    padding: var(--space-xs) var(--space-md);
    font-size: 0.8rem;
    color: var(--ink-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: all 0.2s var(--ease-out);
    letter-spacing: 0.04em;
}

.feedback-link:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-bg);
}

.share-buttons {
    display: flex;
    gap: var(--space-xs);
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--ink-muted);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.share-btn:hover {
    color: var(--ink-primary);
    border-color: var(--ink-secondary);
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

.share-btn:active {
    transform: translateY(0);
}

.share-btn svg {
    flex-shrink: 0;
}

/* ===== EDITOR SECTION ===== */
.editor-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    margin-bottom: var(--space-3xl);
    position: relative;
}

/* Decorative connection line between textareas */
.editor-section::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-primary);
    z-index: 10;
}

.editor-section::after {
    content: '→';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.25rem;
    color: var(--ink-muted);
    z-index: 11;
}

.input-area,
.output-area {
    display: flex;
    flex-direction: column;
}

.input-area label,
.output-area label {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-md);
    color: var(--ink-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.input-area label::before {
    content: '入';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--ink-primary);
    color: var(--bg-primary);
    font-size: 0.7rem;
    border-radius: 4px;
}

.output-area label::before {
    content: '出';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    border-radius: 4px;
}

textarea {
    width: 100%;
    height: 320px;
    padding: var(--space-lg);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--ink-primary);
    font-size: 0.95rem;
    font-family: var(--font-body);
    line-height: 1.9;
    resize: vertical;
    transition: all 0.3s var(--ease-out);
    box-shadow: var(--shadow-sm);
}

textarea:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

textarea:focus {
    outline: none;
    border-color: var(--ink-primary);
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(45, 42, 38, 0.04);
}

textarea::placeholder {
    color: var(--ink-light);
    font-style: italic;
}

#outputText {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--accent-bg) 100%);
}

#outputText:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(199, 62, 58, 0.06);
}

.input-stats,
.output-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-md);
    font-size: 0.8rem;
    color: var(--ink-muted);
    font-family: var(--font-body);
    letter-spacing: 0.02em;
}

.btn-copy {
    padding: var(--space-sm) var(--space-lg);
    background: var(--ink-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: var(--font-body);
    letter-spacing: 0.08em;
    transition: all 0.25s var(--ease-out);
    position: relative;
    overflow: hidden;
}

.btn-copy::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s var(--ease-out);
}

.btn-copy span,
.btn-copy {
    position: relative;
    z-index: 1;
}

.btn-copy:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-copy:hover:not(:disabled)::before {
    transform: scaleX(1);
}

.btn-copy:active:not(:disabled) {
    transform: translateY(0);
}

.btn-copy:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-regenerate {
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    color: var(--ink-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font-body);
    letter-spacing: 0.04em;
    transition: all 0.25s var(--ease-out);
}

.btn-regenerate:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-bg);
}

/* ===== OPTIONS SECTION ===== */
.options-section {
    background: var(--bg-card);
    border-radius: 16px;
    padding: var(--space-2xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    position: relative;
}

.options-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: var(--space-2xl);
    right: var(--space-2xl);
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-soft), transparent);
    border-radius: 0 0 2px 2px;
}

.options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.options-header h2 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--ink-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.options-header h2::before {
    content: '';
    display: block;
    width: 4px;
    height: 20px;
    background: var(--accent);
    border-radius: 2px;
}

.header-buttons {
    display: flex;
    gap: var(--space-sm);
}

.btn-small {
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    color: var(--ink-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font-body);
    letter-spacing: 0.04em;
    transition: all 0.25s var(--ease-out);
}

.btn-small:hover {
    background: var(--bg-secondary);
    color: var(--ink-primary);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.btn-small:active {
    transform: translateY(0);
}

/* Option Groups */
.option-group {
    margin-bottom: var(--space-2xl);
    animation: fadeInUp 0.5s var(--ease-out) backwards;
}

.option-group:nth-child(2) { animation-delay: 0.05s; }
.option-group:nth-child(3) { animation-delay: 0.1s; }
.option-group:nth-child(4) { animation-delay: 0.15s; }
.option-group:nth-child(5) { animation-delay: 0.2s; }
.option-group:nth-child(6) { animation-delay: 0.25s; }

.option-group:last-child {
    margin-bottom: 0;
}

.option-group h3 {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink-secondary);
    margin-bottom: var(--space-md);
    padding-left: var(--space-md);
    position: relative;
    letter-spacing: 0.08em;
}

.option-group h3::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 14px;
    background: var(--accent-soft);
    border-radius: 2px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-sm);
}

/* Individual Options */
.option {
    display: flex;
    align-items: flex-start;
    padding: var(--space-md) var(--space-md);
    background: var(--bg-primary);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s var(--ease-out);
    position: relative;
}

.option:hover {
    background: var(--bg-secondary);
    border-color: var(--border);
    transform: translateX(4px);
}

.option:has(input:checked) {
    background: var(--accent-bg);
    border-color: var(--accent-soft);
}

.option:has(input:checked):hover {
    border-color: var(--accent);
}

.option input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-right: var(--space-md);
    margin-top: 2px;
    border: 1.5px solid var(--ink-light);
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s var(--ease-out);
    background: var(--bg-card);
}

.option input[type="checkbox"]:hover {
    border-color: var(--ink-secondary);
}

.option input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.option input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.option input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.option-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.option-title {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--ink-primary);
    letter-spacing: 0.02em;
    transition: color 0.2s;
}

.option:has(input:checked) .option-title {
    color: var(--accent);
}

.option-desc {
    font-size: 0.75rem;
    color: var(--ink-muted);
    line-height: 1.5;
}

/* ===== FOOTER ===== */
footer {
    text-align: center;
    padding: var(--space-3xl) 0 var(--space-xl);
    color: var(--ink-muted);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    position: relative;
}

footer::before {
    content: '';
    position: absolute;
    top: var(--space-xl);
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 1px;
    background: var(--border);
}

footer p {
    font-family: var(--font-body);
}

/* ===== MOBILE COPY BAR (hidden on desktop) ===== */
.mobile-copy-bar {
    display: none;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: var(--space-2xl);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--ink-primary);
    color: var(--bg-primary);
    padding: var(--space-md) var(--space-xl);
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s var(--ease-out);
    z-index: 1000;
    box-shadow: var(--shadow-float);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered load animation for main sections */
header {
    animation: fadeInUp 0.6s var(--ease-out) 0.1s backwards;
}

.editor-section {
    animation: fadeInUp 0.6s var(--ease-out) 0.2s backwards;
}

.options-section {
    animation: fadeInUp 0.6s var(--ease-out) 0.3s backwards;
}

footer {
    animation: fadeInUp 0.6s var(--ease-out) 0.4s backwards;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .container {
        padding: var(--space-lg) var(--space-md);
    }

    .editor-section {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    .editor-section::before,
    .editor-section::after {
        display: none;
    }

    header h1 {
        font-size: 1.75rem;
    }

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

    textarea {
        height: 200px;
    }

    .options-section {
        padding: var(--space-lg);
    }
}

@media (max-width: 600px) {
    :root {
        font-size: 14px;
    }

    .container {
        padding: var(--space-md) var(--space-sm);
        padding-bottom: 80px; /* Space for fixed copy button */
    }

    header {
        margin-bottom: var(--space-md);
        padding: var(--space-sm) 0;
    }

    header::before {
        display: none;
    }

    header h1 {
        font-size: 1.1rem;
        letter-spacing: 0.02em;
    }

    header h1::after {
        display: none;
    }

    .subtitle {
        display: none;
    }

    .header-actions {
        gap: var(--space-sm);
        margin-top: var(--space-xs);
    }

    .feedback-link {
        padding: 2px var(--space-sm);
        font-size: 0.7rem;
        border-radius: 12px;
    }

    .share-btn {
        width: 28px;
        height: 28px;
    }

    .share-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Editor Section - Mobile */
    .editor-section {
        gap: var(--space-lg);
        margin-bottom: var(--space-xl);
    }

    .input-area label,
    .output-area label {
        font-size: 0.85rem;
        margin-bottom: var(--space-sm);
    }

    .input-area label::before,
    .output-area label::before {
        width: 20px;
        height: 20px;
        font-size: 0.6rem;
    }

    textarea {
        height: 160px;
        padding: var(--space-md);
        font-size: 16px; /* Prevent iOS zoom on focus */
        border-radius: 10px;
    }

    .input-stats,
    .output-actions {
        font-size: 0.75rem;
        margin-top: var(--space-sm);
    }

    /* Hide inline copy button on mobile */
    .output-actions .btn-copy {
        display: none;
    }

    /* Options Section - Mobile */
    .options-section {
        padding: var(--space-md);
        border-radius: 12px;
        margin: 0 calc(-1 * var(--space-sm));
        width: calc(100% + var(--space-md));
    }

    .options-section::before {
        left: var(--space-md);
        right: var(--space-md);
    }

    .options-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
        margin-bottom: var(--space-lg);
        padding-bottom: var(--space-md);
    }

    .options-header h2 {
        font-size: 1rem;
    }

    .options-header h2::before {
        width: 3px;
        height: 16px;
    }

    .header-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-sm);
    }

    .btn-small {
        text-align: center;
        padding: var(--space-sm) var(--space-sm);
        font-size: 0.8rem;
        min-height: 44px; /* Touch target */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Option Groups - Mobile */
    .option-group {
        margin-bottom: var(--space-lg);
    }

    .option-group h3 {
        font-size: 0.85rem;
        margin-bottom: var(--space-sm);
        padding-left: var(--space-sm);
    }

    .option-group h3::before {
        width: 2px;
        height: 12px;
    }

    .options-grid {
        gap: var(--space-xs);
    }

    /* Individual Options - Mobile Touch Optimized */
    .option {
        padding: var(--space-md);
        border-radius: 8px;
        min-height: 56px;
        align-items: center;
    }

    .option:hover {
        transform: none; /* Disable hover transform on touch */
    }

    .option:active {
        background: var(--bg-secondary);
        transform: scale(0.98);
    }

    .option input[type="checkbox"] {
        width: 22px;
        height: 22px;
        margin-right: var(--space-md);
        margin-top: 0;
    }

    .option input[type="checkbox"]:checked::after {
        top: 3px;
        left: 6px;
        width: 6px;
        height: 10px;
    }

    .option-content {
        gap: 1px;
    }

    .option-title {
        font-size: 0.9rem;
    }

    .option-desc {
        font-size: 0.7rem;
        line-height: 1.4;
    }

    /* Footer - Mobile */
    footer {
        padding: var(--space-xl) 0 var(--space-lg);
        font-size: 0.7rem;
    }

    footer::before {
        width: 32px;
    }

    /* Fixed Copy Button - Mobile */
    .mobile-copy-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        padding: var(--space-sm) var(--space-md);
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-md);
        z-index: 100;
        box-shadow: 0 -4px 20px rgba(45, 42, 38, 0.08);
    }

    .mobile-copy-bar .char-info {
        font-size: 0.75rem;
        color: var(--ink-muted);
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .mobile-copy-bar .btn-copy-mobile {
        padding: var(--space-md) var(--space-xl);
        background: var(--accent);
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 0.9rem;
        font-weight: 600;
        font-family: var(--font-body);
        letter-spacing: 0.06em;
        min-height: 48px;
        min-width: 120px;
        cursor: pointer;
        transition: all 0.2s var(--ease-out);
    }

    .mobile-copy-bar .btn-copy-mobile:active {
        transform: scale(0.96);
        background: #a83532;
    }

    .mobile-copy-bar .btn-copy-mobile:disabled {
        background: var(--ink-light);
        cursor: not-allowed;
    }

    /* Toast - Mobile */
    .toast {
        bottom: 80px;
        left: var(--space-md);
        right: var(--space-md);
        transform: translateY(20px);
        text-align: center;
    }

    .toast.show {
        transform: translateY(0);
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    .container {
        padding: var(--space-sm);
        padding-bottom: 80px;
    }

    header h1 {
        font-size: 1.3rem;
    }

    textarea {
        height: 140px;
    }

    .option {
        padding: var(--space-sm) var(--space-md);
    }

    .mobile-copy-bar .btn-copy-mobile {
        min-width: 100px;
        padding: var(--space-md) var(--space-md);
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    body::before {
        display: none;
    }

    .options-section,
    .btn-copy,
    .header-buttons,
    footer {
        display: none;
    }

    .editor-section {
        display: block;
    }

    textarea {
        border: 1px solid #ccc;
        height: auto;
        min-height: 200px;
    }
}
