:root {
  --bg: #ffffff;
  --panel: #f4f4f5;
  --border: #d8d8dc;
  --text: #1e1f22;
  --muted: #6b6d74;
  --accent: #5865f2;
}

:root[data-theme="dark"] {
  --bg: #1e1f22;
  --panel: #2b2d31;
  --border: #3f4147;
  --text: #e3e5e8;
  --muted: #9a9ca3;
  --accent: #5865f2;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  font-family: "맑은 고딕", "Malgun Gothic", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background-color: var(--border);
  background-clip: padding-box;
  border: 2px solid var(--bg);
  border-radius: 6px;
}

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 50px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right {
  display: flex;
  gap: 6px;
}

.topbar button {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.topbar button.accent {
  background: var(--accent);
  color: white;
  border: none;
}

main#notepad {
  position: absolute;
  top: 50px;
  bottom: 52px;
  left: 0;
  right: 0;
  overflow-y: auto;
  padding: 16px;
  line-height: 1.7;
  font-size: 15px;
  outline: none;
  word-break: break-word;
  white-space: pre-wrap;
  -webkit-user-select: text;
}

main#notepad img {
  max-width: 90%;
  border-radius: 4px;
  margin: 4px 0;
  resize: both;
  overflow: hidden;
  display: inline-block;
  min-width: 40px;
  min-height: 40px;
}

main#notepad table {
  border-collapse: collapse;
  margin: 8px 0;
  max-width: 100%;
  display: block;
  overflow-x: auto;
}

main#notepad table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  min-width: 50px;
}

.toolbar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  height: 52px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
}

.toolbar select,
.toolbar button {
  flex: 0 0 auto;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
}

font[size="1"] { font-size: 11px; }
font[size="2"] { font-size: 12px; }
font[size="3"] { font-size: 15px; }
font[size="4"] { font-size: 18px; }
font[size="5"] { font-size: 22px; }
font[size="6"] { font-size: 28px; }
font[size="7"] { font-size: 36px; }

.search-bar {
  position: fixed;
  top: 50px;
  left: 0; right: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.search-bar.hidden { display: none; }

.search-bar input {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}

.search-bar button {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
}

.search-bar #searchCount {
  font-size: 12px;
  color: var(--muted);
  min-width: 40px;
  text-align: center;
}

mark.search-hit {
  background: #ffe58a;
  color: #1e1f22;
  border-radius: 2px;
}

mark.search-hit.current {
  background: #ff9d3d;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  width: min(320px, 86vw);
}

.modal-box h2 { margin-top: 0; font-size: 16px; }

.modal-box label {
  display: block;
  margin: 12px 0;
  font-size: 14px;
  color: var(--muted);
}

.modal-box input {
  display: block;
  margin-top: 4px;
  padding: 8px;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.modal-actions {
  margin-top: 16px;
  text-align: right;
}

.modal-actions button {
  margin-left: 8px;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

#exportConfirm, #tableConfirm { background: var(--accent); color: white; }
#exportCancel, #tableCancel { background: var(--border); color: var(--text); }
