:root {
  --page: #f5f9ff; --panel: #ffffff; --panel-blue: #edf5ff; --blue-soft: #dcecff;
  --blue-pale: #f0f6ff; --blue: #3578d4; --blue-dark: #245da9; --blue-ink: #1d3f69;
  --ink: #26384d; --muted: #71849b; --line: #d9e6f5; --danger: #b5535b;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  color: var(--ink); background: var(--page);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--page); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 282px minmax(430px, 1fr) minmax(340px, 430px); }
.library-panel, .insight-panel { min-height: 100vh; }
.library-panel { background: #eaf3ff; border-right: 1px solid var(--line); padding: 26px 20px 18px; display: flex; flex-direction: column; }
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; color: var(--blue-ink); }
.brand-row div:last-child { display: flex; flex-direction: column; gap: 1px; }
.brand-row strong { font-family: Georgia, "Times New Roman", serif; font-size: 21px; letter-spacing: .02em; }
.brand-row span { color: var(--muted); font-size: 12px; }
.brand-mark { width: 52px; height: 52px; border-radius: 16px; background: linear-gradient(145deg, #6aa6ee, #397bd3); color: white; display: grid; place-items: center; font-family: Georgia, serif; font-size: 24px; box-shadow: 0 10px 25px rgba(52,111,190,.18); }
.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 19px; }

.new-record-button { border: 0; background: var(--blue); color: white; border-radius: 11px; padding: 12px 15px; text-align: left; box-shadow: 0 7px 18px rgba(53,120,212,.16); transition: .2s; }
.new-record-button:hover { background: var(--blue-dark); transform: translateY(-1px); }
.new-record-button span { margin-right: 8px; font-size: 18px; }
.search-box { margin: 16px 0 14px; display: flex; align-items: center; gap: 8px; color: #85a0bf; background: rgba(255,255,255,.75); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.search-box:focus-within { border-color: #8bb7ec; box-shadow: 0 0 0 3px rgba(53,120,212,.08); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.search-box input::placeholder { color: #9aacc0; }

.library-nav { display: grid; gap: 3px; padding: 4px 0 12px; border-bottom: 1px solid var(--line); }
.nav-button { border: 0; background: transparent; border-radius: 9px; color: #58708d; display: flex; justify-content: space-between; align-items: center; padding: 9px 10px; font-size: 13px; text-align: left; }
.nav-button:hover { background: rgba(255,255,255,.65); }
.nav-button.active { background: white; color: var(--blue-dark); font-weight: 650; box-shadow: 0 4px 14px rgba(76,115,160,.07); }
.nav-button b { min-width: 23px; border-radius: 999px; background: #dbeaff; color: #4d78a9; padding: 2px 6px; font-size: 10px; text-align: center; }
.nav-button.active b { background: var(--blue); color: white; }

.topic-browser { padding: 13px 0 7px; border-bottom: 1px solid var(--line); }
.topic-browser > p { margin: 0 0 9px; color: var(--muted); font-size: 11px; }
.topic-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 126px; overflow: auto; }
.topic-button { border: 1px solid #cddff3; background: rgba(255,255,255,.72); color: #56718f; border-radius: 999px; padding: 5px 8px; font-size: 10px; }
.topic-button.active { border-color: var(--blue); background: var(--blue); color: white; }
.topic-button span { opacity: .72; margin-left: 4px; }

.library-heading { display: flex; justify-content: space-between; padding: 15px 6px 9px; color: var(--muted); font-size: 11px; }
.record-list { flex: 1; overflow: auto; margin: 0 -7px; padding: 0 3px; scrollbar-width: thin; }
.record-item { width: 100%; border: 1px solid transparent; border-radius: 10px; color: #516b88; background: transparent; text-align: left; padding: 12px; margin-bottom: 4px; }
.record-item:hover { background: rgba(255,255,255,.72); }
.record-item.active { background: white; border-color: #d8e7f7; color: var(--blue-ink); box-shadow: 0 5px 16px rgba(64,104,151,.07); }
.record-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.record-item span { display: block; color: #91a4ba; font-size: 11px; margin-top: 6px; }
.empty-list { margin: 24px 8px; color: #8ca0b7; font-size: 12px; line-height: 1.7; text-align: center; }
.text-button { border: 0; background: transparent; color: inherit; }
.logout-button { color: #8298b2; font-size: 11px; align-self: flex-start; padding: 10px 5px 0; }
.install-button { width: 100%; border: 1px solid #b9d3ef; background: rgba(255,255,255,.82); color: var(--blue-dark); border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 12px; font-weight: 650; }
.install-button:hover { border-color: var(--blue); background: white; }

.editor-panel { height: 100vh; height: 100dvh; min-height: 520px; overflow: hidden; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); }
.editor-header { min-height: 82px; padding: 18px 32px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e7eef7; background: rgba(255,255,255,.92); }
.date-label { font-size: 12px; color: var(--muted); margin: 0 0 4px; }
.save-state { font-size: 12px; color: var(--blue); margin: 0; }
.editor-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.secondary-button, .icon-button { border: 1px solid #cfdef0; background: white; color: #58718d; border-radius: 8px; padding: 8px 12px; font-size: 12px; }
.secondary-button:hover, .icon-button:hover { border-color: #93b9e7; background: var(--blue-pale); color: var(--blue-dark); }
.writing-surface { flex: 1; min-height: 0; overflow: auto; padding: 52px clamp(38px, 7vw, 90px) 28px; display: flex; flex-direction: column; }
.title-input { border: 0; outline: 0; background: transparent; color: #20354f; font-family: Georgia, "Noto Serif KR", serif; font-size: clamp(24px, 3vw, 34px); line-height: 1.3; margin-bottom: 27px; }
.title-input::placeholder { color: #aebed0; }
.content-input { flex: 1; min-height: 320px; resize: none; border: 0; outline: 0; background: transparent; color: #2d4057; font-family: Georgia, "Noto Serif KR", serif; font-size: 17px; line-height: 2; caret-color: var(--blue); }
.content-input::placeholder { color: #aebed0; }
.content-input:disabled, .title-input:disabled { color: #75869a; }
.editor-footer { flex: 0 0 auto; position: relative; z-index: 5; padding: 19px 32px 23px; border-top: 1px solid #e7eef7; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; background: #fbfdff; box-shadow: 0 -8px 24px rgba(49,92,143,.05); }
.primary-button { border: 0; border-radius: 9px; color: white; background: var(--blue); padding: 12px 18px; font-weight: 650; box-shadow: 0 6px 15px rgba(53,120,212,.16); transition: .2s; }
.primary-button:hover { background: var(--blue-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: .58; cursor: wait; transform: none; }
.analyze-button { min-width: 182px; }

.insight-panel { background: #f4f8fe; padding: 30px clamp(24px, 3vw, 42px); overflow: auto; }
.insight-header { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.insight-header h2 { margin: 0; font-family: Georgia, "Noto Serif KR", serif; font-size: 21px; color: var(--blue-ink); font-weight: 500; }
.eyebrow { margin: 0 0 7px; font-size: 10px; letter-spacing: .16em; color: var(--blue); font-weight: 750; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #b6c5d6; margin-top: 7px; }
.status-dot.online { background: #4c9c7b; box-shadow: 0 0 0 4px rgba(76,156,123,.1); }
.empty-insight { min-height: 64vh; display: grid; place-items: center; align-content: center; text-align: center; color: #7f93aa; font-family: Georgia, "Noto Serif KR", serif; font-size: 14px; line-height: 1.9; }
.empty-orbit { width: 74px; height: 74px; border: 1px solid #bad1eb; border-radius: 50%; position: relative; margin-bottom: 20px; background: rgba(255,255,255,.55); }
.empty-orbit::after { content: ""; position: absolute; inset: 12px; border: 1px solid #d4e4f5; border-radius: 50%; }
.empty-orbit span { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); top: 5px; left: 31px; }
.insight-content { padding-top: 28px; }
.analysis-text { font-family: Georgia, "Noto Serif KR", serif; color: #344a64; font-size: 15px; line-height: 1.9; white-space: pre-wrap; }
.analysis-text a { color: var(--blue-dark); text-underline-offset: 3px; }
.metadata-section { margin-top: 33px; border-top: 1px solid var(--line); padding-top: 19px; }
.metadata-row { display: flex; justify-content: space-between; gap: 15px; font-size: 12px; }
.metadata-label { color: var(--muted); }
.metadata-row strong { color: var(--blue-dark); }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.tag { border: 1px solid #bfd5ed; background: rgba(255,255,255,.7); border-radius: 999px; padding: 5px 9px; color: #52779f; font-size: 11px; }
.potential-box { background: #e4f0ff; border: 1px solid #d2e4fa; border-radius: 11px; padding: 15px 17px; margin-top: 18px; }
.potential-box span { color: var(--blue-dark); font-size: 10px; font-weight: 750; letter-spacing: .08em; }
.potential-box p { margin: 7px 0 0; color: #3f5f82; font-size: 13px; line-height: 1.7; }
.app-message { min-height: 20px; margin: 21px 0 0; color: var(--danger); font-size: 12px; line-height: 1.6; }

.login-view { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 50% 25%, #ffffff, #e6f1ff); padding: 24px; }
.login-card { width: min(390px, 100%); padding: 47px 42px; text-align: center; background: rgba(255,255,255,.9); border: 1px solid #d7e6f7; border-radius: 20px; box-shadow: 0 22px 65px rgba(66,111,166,.12); }
.login-card .brand-mark { margin: 0 auto 25px; }
.login-card h1 { margin: 0; color: var(--blue-ink); font-family: Georgia, "Noto Serif KR", serif; font-size: 24px; font-weight: 500; }
.login-copy { margin: 12px 0 28px; color: var(--muted); font-size: 13px; }
.login-card input { width: 100%; border: 1px solid #ccdef2; background: white; border-radius: 9px; padding: 13px 14px; outline: 0; }
.login-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53,120,212,.09); }
.login-card .primary-button { width: 100%; margin-top: 11px; }
.form-error { min-height: 18px; color: var(--danger); font-size: 12px; margin: 12px 0 0; }

.proofread-dialog { width: min(760px, calc(100% - 32px)); border: 0; border-radius: 18px; padding: 0; color: var(--ink); box-shadow: 0 25px 80px rgba(31,66,108,.25); }
.proofread-dialog::backdrop { background: rgba(31,56,87,.26); backdrop-filter: blur(3px); }
.dialog-card { padding: 28px; background: white; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-header h2 { margin: 0; color: var(--blue-ink); font-family: Georgia, "Noto Serif KR", serif; font-size: 22px; font-weight: 500; }
.dialog-close { border: 0; background: var(--blue-pale); color: #69829d; border-radius: 50%; width: 32px; height: 32px; font-size: 20px; }
.dialog-guide { margin: 15px 0; color: var(--muted); font-size: 12px; }
.corrected-text { width: 100%; min-height: 260px; resize: vertical; border: 1px solid #cfdef0; border-radius: 11px; padding: 17px; color: #30465f; font-family: Georgia, "Noto Serif KR", serif; font-size: 15px; line-height: 1.85; outline: 0; }
.corrected-text:focus { border-color: #8bb7ec; box-shadow: 0 0 0 3px rgba(53,120,212,.08); }
.proofread-changes { max-height: 165px; overflow: auto; margin-top: 14px; display: grid; gap: 7px; }
.change-item { border-radius: 8px; background: var(--blue-pale); padding: 9px 11px; color: #58708d; font-size: 11px; line-height: 1.55; }
.change-item strong { color: var(--blue-dark); }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 19px; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 240px 1fr; }
  .insight-panel { grid-column: 2; min-height: auto; border-top: 1px solid var(--line); }
  .empty-insight { min-height: 300px; }
}
@media (max-width: 720px) {
  .app-shell { display: block; }
  .library-panel { min-height: auto; padding: 15px; }
  .brand-row { margin-bottom: 14px; }
  .new-record-button { width: 100%; }
  .library-nav { grid-template-columns: repeat(3, 1fr); border-bottom: 0; padding-bottom: 3px; }
  .nav-button { justify-content: center; gap: 5px; padding: 8px 5px; font-size: 11px; }
  .search-box, .topic-browser, .library-heading, .record-list, .logout-button { display: none; }
  .install-button { margin-top: 8px; }
  .editor-panel { height: 78vh; height: 78dvh; min-height: 0; border-right: 0; }
  .editor-header { height: auto; min-height: 68px; padding: 12px 17px; gap: 10px; }
  .editor-actions { max-width: 65%; }
  .secondary-button, .icon-button { padding: 7px 9px; font-size: 10px; }
  .writing-surface { padding: 34px 22px 20px; }
  .content-input { min-height: 330px; font-size: 16px; }
  .editor-footer { padding: 15px 17px; }
  .analyze-button { min-width: 0; }
  .insight-panel { min-height: 55vh; padding: 26px 22px; }
  .dialog-card { padding: 21px; }
}
