/* App_Ai 웹 화면의 스타일을 정의한다. */
    :root {
      color-scheme: light;
      --bg: #f6f8fb;
      --panel: #ffffff;
      --text: #172033;
      --muted: #657189;
      --line: #dfe5ef;
      --primary: #005bac;
      --primary-dark: #00437f;
      --danger: #b3261e;
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      min-height: 100vh;
      background:
        linear-gradient(135deg, rgba(0, 91, 172, 0.10), transparent 34%),
        linear-gradient(315deg, rgba(0, 163, 224, 0.12), transparent 38%),
        var(--bg);
      color: var(--text);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    main {
      width: min(1440px, calc(100% - 32px));
      margin: 0 auto;
      padding: 56px 0;
    }

    h1 {
      margin: 0 0 22px;
      font-size: 28px;
      line-height: 1.2;
    }

    .app-title {
      display: grid;
      gap: 6px;
    }

    .app-title small {
      color: var(--muted);
      font-size: 13px;
      font-weight: 650;
      line-height: 1.45;
      overflow-wrap: anywhere;
    }

    .app-layout {
      display: grid;
      grid-template-columns: minmax(0, 760px) minmax(480px, 1fr);
      gap: 18px;
      align-items: start;
    }

    .workspace,
    .side-log {
      overflow: hidden;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.88);
      box-shadow: 0 18px 50px rgba(24, 42, 67, 0.10);
    }

    .side-log {
      position: sticky;
      top: 18px;
      padding: 14px;
    }

	    .tabs {
	      display: flex;
	      gap: 8px;
	      padding: 8px;
	      border-bottom: 1px solid var(--line);
	      background: #f8fbff;
	      align-items: center;
	    }

    .tab-button {
      min-height: 38px;
      border: 1px solid #c6d3e3;
      border-radius: 8px;
      padding: 0 14px;
      background: white;
      color: #315173;
      font: inherit;
      font-weight: 650;
      cursor: pointer;
    }

    .tab-button.active {
      border-color: var(--primary);
      color: var(--primary);
      box-shadow: inset 0 0 0 1px rgba(0, 91, 172, 0.25);
    }

    .tab-pane {
      display: none;
    }

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

    .input-area,
    .settings-body,
    .answer {
      padding: 22px;
      background: var(--panel);
    }

    .input-area {
      border-bottom: 1px solid var(--line);
    }

    label {
      display: block;
      margin-bottom: 10px;
      color: var(--muted);
      font-size: 14px;
      font-weight: 650;
    }

    textarea,
    input[type="url"],
    input[type="text"] {
      width: 100%;
      border: 1px solid #cbd5e3;
      border-radius: 8px;
      padding: 16px;
      outline: none;
      background: #fbfdff;
      color: var(--text);
      font: inherit;
    }

    textarea {
      min-height: 116px;
      resize: vertical;
      line-height: 1.55;
    }

    textarea:focus,
    input[type="url"]:focus,
    input[type="text"]:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(0, 91, 172, 0.14);
    }

    button {
      min-height: 42px;
      border: 0;
      border-radius: 8px;
      padding: 0 18px;
      background: var(--primary);
      color: white;
      font: inherit;
      font-weight: 750;
      cursor: pointer;
    }

    button:hover {
      background: var(--primary-dark);
    }

    button:disabled {
      cursor: wait;
      opacity: 0.62;
    }

    .ghost {
      border: 1px solid #c6d3e3;
      background: #eff4fb;
      color: #3f5978;
    }

    .answer {
      min-height: 220px;
      background: linear-gradient(180deg, #ffffff, #f9fbfe);
    }

    .answer-title {
      margin: 0 0 12px;
      color: var(--muted);
      font-size: 14px;
      font-weight: 750;
    }

    #result {
      margin: 0;
      overflow-wrap: anywhere;
      word-break: keep-all;
      line-height: 1.48;
      font-size: 16px;
    }

    #result > :first-child {
      margin-top: 0;
    }

    #result > :last-child {
      margin-bottom: 0;
    }

    #result p {
      margin: 0.7em 0;
      white-space: pre-wrap;
    }

    #result h1,
    #result h2,
    #result h3 {
      margin: 1.1em 0 0.45em;
      color: #1c3d61;
      line-height: 1.35;
    }

    #result h1 { font-size: 1.25em; }
    #result h2 { font-size: 1.14em; }
    #result h3 { font-size: 1.04em; }

    #result ul,
    #result ol {
      margin: 0.55em 0;
      padding-left: 1.35em;
    }

    #result li + li {
      margin-top: 0.28em;
    }

    #result code {
      border-radius: 4px;
      padding: 0.1em 0.3em;
      background: #eaf1f8;
      color: #244968;
      font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    }

    #result pre {
      margin: 0.8em 0;
      overflow-x: auto;
      border-radius: 7px;
      padding: 12px;
      background: #0f172a;
      color: #d1fae5;
    }

    #result pre code {
      padding: 0;
      background: transparent;
      color: inherit;
    }

    #result a {
      color: var(--primary);
      text-decoration: underline;
    }

    .empty {
      color: var(--muted);
    }

    .error {
      color: var(--danger);
    }

    .source-list {
      display: grid;
      gap: 10px;
      margin: 0;
      padding: 0;
      list-style: none;
    }

    .source-item {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
      align-items: center;
    }

    .source-item.with-open-button,
    .source-item.with-upload-button {
      grid-template-columns: 1fr auto auto;
    }

    .source-section + .source-section {
      margin-top: 22px;
    }

    .inline-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
      margin-top: 14px;
    }

	    .toggle {
	      display: inline-flex;
	      align-items: center;
	      gap: 8px;
	      color: var(--muted);
	      font-size: 14px;
	      font-weight: 650;
	      user-select: none;
	    }

	    .switch-toggle {
	      min-height: 42px;
	      padding: 0 10px;
	      border: 1px solid #c6d3e3;
	      border-radius: 8px;
	      background: #fbfdff;
	    }

	    .tab-toggle {
	      margin-left: auto;
	    }

    input[type="checkbox"] {
      width: 16px;
      height: 16px;
      accent-color: var(--primary);
    }

    #settingsStatus {
      margin-top: 12px;
      color: var(--muted);
      font-size: 14px;
    }

    .log-panel {
      margin: 0;
      overflow: hidden;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #0f172a;
    }

    .log-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 10px 14px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.12);
      color: #dbeafe;
      font-size: 13px;
      font-weight: 750;
    }

    .log-status {
      color: #93c5fd;
      font-size: 12px;
      font-weight: 650;
    }

    #questionLog,
    #rebuildLog {
      height: min(620px, calc(100vh - 180px));
      min-height: 360px;
      margin: 0;
      padding: 14px;
      overflow: auto;
      background: #0f172a;
      color: #d1fae5;
      font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      white-space: pre-wrap;
      word-break: break-word;
    }

    @media (max-width: 980px) {
      main {
        width: min(100% - 22px, 920px);
        padding: 26px 0;
      }

      h1 {
        font-size: 22px;
      }

      .app-layout {
        grid-template-columns: 1fr;
      }

      .side-log {
        position: static;
        padding: 12px;
      }

      #questionLog,
      #rebuildLog {
        height: 220px;
        min-height: 220px;
      }

      .input-area,
      .answer,
      .settings-body {
        padding: 16px;
      }
    }

    @media (max-width: 640px) {
      button {
        width: 100%;
      }

      .source-item {
        grid-template-columns: 1fr;
      }
    }
