/* --- Base & Variables --- */
:root {
    --bg-color: #f9f9f9;
    --card-bg-color: #ffffff;
    --text-color: #1d1d1f;
    --secondary-text-color: #6e6e73;
    --accent-color: #007aff;
    --border-color: #d2d2d7;
    --input-bg-color: #f2f2f7;
    --button-hover-bg: #ebebf0; /* Slightly darker hover */
    --control-icon-bg: transparent; /* Default icon background */
    --control-icon-hover-bg: #e5e5ea; /* Darker hover for icons */
    --destructive-color: #ff3b30;
    --success-color: #34c759;
    --warning-color: #ff9500;
    --border-radius: 12px;
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    /* MODIFIED: Increased default icon size */
    --icon-size: 24px; /* Larger icon size variable */
    --guide-icon-size: 28px; /* Icon size for guide headers */
    --feature-icon-size: 22px; /* Icon size for feature items */
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #000000;
        --card-bg-color: #1c1c1e;
        --text-color: #ffffff;
        --secondary-text-color: #8e8e93;
        --accent-color: #0a84ff;
        --border-color: #3a3a3c;
        --input-bg-color: #1c1c1e; /* Match textbox bg */
        --button-hover-bg: #2c2c2e;
        --control-icon-bg: transparent;
        --control-icon-hover-bg: #3a3a3c; /* Darker hover for icons */
    }
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Layout & Container --- */
.container {
    max-width: 700px;
    margin: 20px auto;
    background-color: var(--card-bg-color);
    padding: 25px 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}

/* --- Header --- */
.app-header {
    display: flex;
    align-items: center; /* Vertically center items (logo and title group) */
    justify-content: center; /* Horizontally center items */
    gap: 15px;
    /* MODIFIED: Reduced bottom margin to move textbox closer */
    margin-bottom: 15px;
    padding-bottom: 15px;
    /* border-bottom: 1px solid var(--border-color); Removed border */
}

.logo {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    flex-shrink: 0; /* Prevent logo from shrinking */
}

.title-group {
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center title/subtitle vertically within its own space */
    /* No fixed height needed, rely on align-items in parent */
    flex-grow: 0; /* Prevent title group from taking extra space */
    text-align: left; /* Explicitly set text align if needed, though centering is via flex parent */
}

.app-header h1 {
    margin: 0;
    font-size: 1.8em;
    font-weight: 600;
    line-height: 1.1; /* Fine-tuned line height */
}

.app-header .subtitle {
    font-size: 0.9em;
    color: var(--secondary-text-color);
    margin: 0; /* 移除上边距，减小间距 */
    line-height: 1.1; /* 保持行高 */
}


/* --- General Form Elements (used in modal) --- */
label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--secondary-text-color);
    font-size: 0.95em;
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 10px 12px; /* Slightly reduced padding */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg-color);
    color: var(--text-color);
    font-size: 1em;
    box-sizing: border-box;
    margin-bottom: 15px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1); /* Slightly smaller shadow */
}

.form-group {
    margin-bottom: 20px;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px; /* Adjusted gap */
    padding-top: 5px;
}

.radio-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0;
    color: var(--text-color);
    font-weight: 400;
    font-size: 0.95em; /* Slightly smaller radio labels */
}

.radio-group input[type="radio"] {
    margin-right: 6px;
    accent-color: var(--accent-color);
}

.button {
    display: inline-block;
    padding: 10px 20px; /* Slightly smaller button */
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    margin-top: 10px;
}

.primary-button {
    background-color: var(--accent-color);
    color: white;
}

.primary-button:hover {
    background-color: #005bb5;
}

.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Output & Loading --- */
.output-section {
    margin-bottom: 25px;
    position: relative; /* For copy button positioning */
}

.result-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 15px 0 20px 0; /* Adjust margins as needed */
}

.output-content-wrapper {
    position: relative; /* Container for pre and copy button */
}

pre {
    background-color: var(--input-bg-color);
    padding: 15px;
    padding-right: 40px; /* Increased space for copy button placement */
    border-radius: 8px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid var(--border-color);
    margin: 0; /* Remove default margin if any */
    position: relative;
}

code {
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.95em;
    color: var(--text-color);
}

.copy-button {
    position: absolute;
    top: 6px; /* Adjusted positioning */
    right: 6px; /* Adjusted positioning */
    background: var(--button-hover-bg);
    border: none;
    border-radius: 6px;
    padding: 3px; /* MODIFIED: Reduced padding */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-text-color);
    transition: background-color 0.2s ease, color 0.2s ease;
}
.copy-button:hover {
    background-color: var(--control-icon-hover-bg);
    color: var(--text-color);
}
.copy-button .material-symbols-outlined {
    font-size: 16px; /* MODIFIED: Reduced icon size */
}

/* --- Tooltip Styling (Specific for Copy Button) --- */
.copy-button[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background-color: rgba(0, 0, 0, 0.85); /* Darker tooltip */
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    margin-bottom: 5px; /* Space between button and tooltip */
    pointer-events: none;
    z-index: 10;
}
.copy-button[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}


.loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--secondary-text-color);
    padding: 15px 0; /* Adjust padding as needed */
}

.spinner {
    border: 3px solid var(--input-bg-color); /* Thinner spinner */
    border-left-color: var(--accent-color);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* --- Guide & Misc --- */
.guide-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.guide-main-title {
    font-size: 1.6em; /* Larger main title */
    font-weight: 600;
    text-align: center;
    margin-bottom: 30px; /* More space below main title */
    color: var(--text-color);
}

.guide-subsection {
    margin-bottom: 30px; /* Space between subsections */
    padding: 15px;
    border-radius: var(--border-radius);
    background-color: var(--input-bg-color); /* Subtle background for subsections */
    border: 1px solid var(--border-color);
}
.guide-subsection.notice {
    background-color: rgba(var(--warning-color-rgb, 255, 149, 0), 0.08); /* Use RGBA for opacity */
    border-color: rgba(var(--warning-color-rgb, 255, 149, 0), 0.3);
}
/* Define CSS variables for RGB components of warning color for cleaner RGBA usage */
:root {
    --warning-color-rgb: 255, 149, 0; /* For --warning-color: #ff9500; */
}
@media (prefers-color-scheme: dark) {
    :root {
      /* Update if your dark mode warning color is different and needs RGB components */
      /* --warning-color-rgb: ...; */
    }
    .guide-subsection.notice {
        background-color: rgba(var(--warning-color-rgb, 255, 149, 0), 0.15); /* Slightly more opaque in dark mode */
        border-color: rgba(var(--warning-color-rgb, 255, 149, 0), 0.4);
    }
}


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

.guide-header-icon {
    width: var(--guide-icon-size);
    height: var(--guide-icon-size);
    opacity: 0.8;
}

.guide-subsection h4 {
    font-size: 1.2em;
    font-weight: 500;
    margin: 0;
    color: var(--text-color);
}

.guide-subsection p {
    color: var(--secondary-text-color);
    margin-bottom: 10px;
    font-size: 0.95em;
    line-height: 1.7; /* Increased line height for readability */
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Responsive grid */
    gap: 15px;
    margin-top: 15px;
}

.feature-item {
    display: flex;
    align-items: flex-start; /* Align items to the top */
    gap: 12px;
    padding: 12px;
    background-color: var(--card-bg-color); /* Slightly different background for items */
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}
.feature-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.07);
}

.feature-icon {
    width: var(--feature-icon-size);
    height: var(--feature-icon-size);
    margin-top: 3px; /* Align icon better with text */
    opacity: 0.7;
    flex-shrink: 0;
}

.feature-text {
    display: flex;
    flex-direction: column;
}

.feature-text strong {
    font-weight: 500;
    font-size: 1em;
    color: var(--text-color);
    margin-bottom: 3px;
}

.feature-text span {
    font-size: 0.9em;
    color: var(--secondary-text-color);
    line-height: 1.5;
}

.tag {
    display: inline-block;
    padding: 2px 6px;
    background-color: var(--input-bg-color);
    color: var(--accent-color); /* Make tags stand out a bit more */
    border-radius: 5px;
    margin: 0 2px;
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.85em;
    border: 1px solid var(--border-color);
}
/* Style for the old guide section elements if any were missed in HTML conversion */
.guide-section h5 { font-size: 1.3em; margin-bottom: 10px; font-weight: 600; }
.guide-section h6 { font-size: 1.1em; margin-top: 15px; margin-bottom: 5px; font-weight: 500; color: var(--secondary-text-color); }
.guide-section ul { padding-left: 20px; color: var(--secondary-text-color); margin-bottom: 10px; font-size: 0.95em;}
.guide-section li { margin-bottom: 5px; }


.hidden { display: none !important; }

/* --- Toast Notification --- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background-color: rgba(50, 50, 50, 0.9); color: white; padding: 10px 20px; border-radius: 20px; font-size: 0.9em; z-index: 1000; display: flex; align-items: center; gap: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); transition: opacity 0.3s ease, transform 0.3s ease; }
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(20px); pointer-events: none; }

/* --- Modern Textbox --- */
.modern-textbox {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--input-bg-color);
    padding: 12px; /* Increased padding */
    padding-bottom: 45px; /* Space for controls */
    box-shadow: var(--card-shadow);
    /* MODIFIED: Keep margin-bottom for spacing below the textbox */
    margin-bottom: 25px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modern-textbox:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
}

.modern-textbox textarea {
    width: 100%;
    border: none;
    background-color: transparent;
    color: var(--text-color);
    /* MODIFIED: Increased font size */
    font-size: 1.5em; /* Slightly larger font size */
    line-height: 1.5; /* Adjust line height */
    box-sizing: border-box;
    resize: none; /* Disable textarea resize */
    min-height: 100px; /* Set a minimum height */
    /* max-height: 250px; */ /* Optional: Set a max height */
    height: 120px; /* Default fixed height */
    overflow-y: auto; /* Enable vertical scroll */
    outline: none;
    padding: 0;
    margin: 0;
}

.textbox-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px; /* Adjusted padding */
    /* Match modern-textbox background */
    background-color: var(--input-bg-color);
    border-top: 1px solid var(--border-color);
    border-bottom-left-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
    height: 38px; /* Fixed height for control bar */
}

.input-type-indicator, /* Renamed */
.action-settings-icons {
    display: flex;
    align-items: center;
    gap: 6px; /* Reduced gap */
}

.control-icon {
    /* MODIFIED: Use updated variable */
    width: var(--icon-size);
    height: var(--icon-size);
    cursor: pointer;
    opacity: 0.7; /* Default opacity */
    transition: opacity 0.2s ease, background-color 0.2s ease;
    /* MODIFIED: Adjusted padding slightly for larger icons */
    padding: 5px;
    border-radius: 6px; /* Slightly rounder */
    position: relative; /* Needed for tooltip positioning */
    background-color: var(--control-icon-bg);
    display: flex; /* Needed for centering icon if using SVG */
    align-items: center;
    justify-content: center;
    /* Prevent icon within link from having default styles */
    vertical-align: middle;
    border: none; /* Remove potential borders */
}

/* Styling for the new token icon (optional, if needed) */
.token-icon {
     /* Add specific styles here if needed, e.g., different opacity */
     opacity: 0.8; /* Example: Make it slightly more visible */
}
.token-icon:hover {
    opacity: 1; /* Ensure full opacity on hover */
}


.current-type-icon.active { /* Style for the main type icon when active */
    opacity: 1;
    /* Example: Add a subtle border */
    /* box-shadow: 0 0 0 1px var(--accent-color); */
}

.control-icon.action-icon {
    opacity: 1; /* Keep action icons fully visible */
}


.control-icon:hover {
    background-color: var(--control-icon-hover-bg); /* Use variable */
    opacity: 1; /* Full opacity on hover */
}

/* --- Tooltip Styling (Specific for Control Icons) --- */
/* Base (Hidden) */
.control-icon[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%; /* Position above the icon */
    left: 50%;
    transform: translateX(-50%) scale(0.8); /* Start scaled down */
    background-color: rgba(0, 0, 0, 0.85); /* Darker tooltip */
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    white-space: nowrap;
    opacity: 0; /* Start hidden */
    visibility: hidden; /* Start hidden */
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none; /* Don't interfere with mouse events */
    z-index: 10; /* Ensure it's above other elements */
}

/* Hover (Visible) */
.control-icon[data-tooltip]:hover::after {
    opacity: 1; /* Fade in */
    visibility: visible; /* Make it visible */
    transform: translateX(-50%) scale(1); /* Scale to full size */
}


/* GO Icon */
.go-icon { opacity: 1; }
/* Disable GO icon */
.go-icon[disabled] {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* --- Selectors (Topic, AI Model) --- */
.topic-selector,
.ai-model-selector {
    position: relative;
    display: flex;
    align-items: center;
}

/* Shared option container style */
.topic-option,
.model-options {
    position: absolute;
    bottom: calc(100% + 4px); /* Position above the control bar */
    right: 0;
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    display: none; /* Hidden by default */
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 5; /* Lower than tooltip (z-index: 10) */
    opacity: 0; /* Start hidden */
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(5px);
    pointer-events: none; /* Start non-interactive */
}
/* Make visible when parent selector has 'open' class */
.topic-selector.open .topic-option,
.ai-model-selector.open .model-options {
    display: flex; /* Show flex container */
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto; /* Allow interaction when open */
}

/* Specifics for Topic Input */
.topic-option {
    padding: 6px; /* Smaller padding */
    display: none; /* Overridden by .open */
}
.topic-selector.open .topic-option {
     display: block; /* Make topic input block when open */
}
.topic-option input {
    width: 130px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9em;
    background-color: var(--input-bg-color);
    outline: none;
    color: var(--text-color);
    margin: 0; /* Remove margin */
}
.topic-option input:focus {
     border-color: var(--accent-color);
}

/* Specifics for Model Options */
.model-options .model-option-icon {
    /* Inherits .control-icon styles */
    width: calc(var(--icon-size) + 4px); /* Slightly larger */
    height: calc(var(--icon-size) + 4px);
    opacity: 0.8;
}
.model-options .model-option-icon:hover {
     opacity: 1;
     background-color: var(--control-icon-hover-bg);
}

/* --- Modal Styling --- */
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 100; transition: opacity 0.3s ease; }
.modal-backdrop.hidden { opacity: 0; pointer-events: none; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: var(--card-bg-color); padding: 25px 30px; border-radius: var(--border-radius); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); z-index: 101; min-width: 300px; max-width: 90%; width: 500px; transition: opacity 0.3s ease, transform 0.3s ease; }
.modal.hidden { opacity: 0; transform: translate(-50%, -45%); pointer-events: none; }
.modal-content { position: relative; }
.modal h3 { margin-top: 0; margin-bottom: 20px; text-align: center; font-weight: 600; color: var(--text-color); }
.close-button { position: absolute; top: -10px; right: 0px; font-size: 1.8em; font-weight: bold; color: var(--secondary-text-color); cursor: pointer; line-height: 1; }
.close-button:hover { color: var(--text-color); }
.modal .form-group { margin-bottom: 15px; }
.modal .button { width: 100%; margin-top: 15px; }
/* Ensure radio groups in modal have adequate spacing */
.modal .radio-group { padding-top: 5px; margin-bottom: 15px; }

/* --- Responsive --- */
@media (max-width: 768px) {
    body { padding: 10px; }
    .container { padding: 20px; margin: 10px auto; }
    .app-header { gap: 10px; } /* Reduce gap */
    .app-header h1 { font-size: 1.5em; } /* Smaller title on mobile */
    .app-header .subtitle { font-size: 0.8em; }
    .button { padding: 10px 20px; width: 100%; box-sizing: border-box; }
    .modal .radio-group { flex-direction: column; align-items: flex-start; }
    .modal .radio-group label { width: 100%; margin-bottom: 5px; }

    .modern-textbox { padding-bottom: 45px; /* Keep height consistent */ }
    .modern-textbox textarea { height: 100px; font-size: 1em; } /* Adjust height/font */
    .textbox-controls { flex-wrap: nowrap; /* Prevent wrapping on small screens */ height: 40px; padding: 5px 8px;}
    .input-type-indicator { order: 1; /* Keep order */ }
    .action-settings-icons { order: 2; }
    /* Adjust gaps if needed */
    .input-type-indicator, .action-settings-icons { gap: 4px; }
    /* MODIFIED: Increased icon size for mobile */
    :root { --icon-size: 22px; } /* Larger icons on mobile */
     /* Make topic input smaller */
     .topic-option input { width: 100px; }
     /* Ensure options don't overflow */
     .topic-option, .model-options { max-width: calc(100vw - 40px); /* Prevent overflow */ }

    .modal { width: 90%; }
    /* MODIFIED: Removed specific copy button styles for mobile as they are now default */
    /* .copy-button { padding: 3px; } */
    /* .copy-button .material-symbols-outlined { font-size: 16px; } */

    .guide-main-title { font-size: 1.4em; margin-bottom: 20px; }
    .guide-subsection { padding: 12px; }
    .guide-subsection h4 { font-size: 1.1em; }
    .features-grid { grid-template-columns: 1fr; /* Stack items on mobile */ }
    .feature-item { padding: 10px; }
    :root {
        --guide-icon-size: 24px;
        --feature-icon-size: 20px;
    }

}
