:root {
  --page: #eef0ec;
  --surface: #fbfbf9;
  --surface-sunken: #e1e5df;
  --ink: #1c201d;
  --muted: #5d655f;
  --accent: #2c5f52;
  --accent-strong: #21483e;
  --accent-soft: #e2e9e3;
  --danger: #8b3a2c;
  --radius: 6px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Noto Sans KR",
    "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
}

.view[hidden] {
  display: none;
}

/* 목록은 문서 흐름대로 페이지 전체가 스크롤된다(안쪽 스크롤 상자는 화면에 선처럼 보인다). */
#list-view {
  height: auto;
  min-height: 100vh;
}

/* ---------------- 목록 ---------------- */

.list-header {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-4);
}

.list-header h1 {
  margin: 0 0 var(--space-2);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  word-break: keep-all;
}

.hint {
  margin: 0 0 var(--space-5);
  max-width: 62ch;
  color: var(--muted);
  font-size: 14px;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.search-form {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  max-width: 380px;
  padding: 9px var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  appearance: none;
}

.search-form input[type="search"]::placeholder {
  color: var(--muted);
}

.button {
  padding: 9px var(--space-4);
  border: 0;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.button:hover {
  background: #d5e0d7;
}

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

.button.primary:hover {
  background: var(--accent-strong);
}

.button:disabled {
  opacity: 0.45;
  cursor: default;
}

.button:disabled:hover {
  background: var(--accent-soft);
}

.button.primary:disabled:hover {
  background: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.status {
  margin: 0;
  min-height: 1.5em;
  color: var(--muted);
  font-size: 13px;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.status[data-kind="error"] {
  color: var(--danger);
}

.status[data-kind="ok"] {
  color: var(--accent-strong);
}

.list-body {
  flex: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 var(--space-3) var(--space-6);
}

.file-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  padding: 11px var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.file-row:hover {
  background: var(--surface);
}

.file-row .file-name {
  font-weight: 550;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.file-row .file-time {
  flex: none;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------------- 편집 ---------------- */

.editor-view {
  background: var(--surface-sunken);
}

.editor-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
}

.file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-meta .file-name {
  font-size: 15px;
  font-weight: 650;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.editor-actions {
  display: flex;
  gap: var(--space-2);
  margin-left: auto;
}

.editor-container {
  position: relative;
  flex: 1;
  min-height: 0;
}

.editor-container iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--surface);
}

@media (max-width: 640px) {
  .list-header {
    padding: var(--space-5) var(--space-4) var(--space-3);
  }

  .search-form input[type="search"] {
    max-width: none;
  }

  .editor-bar {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .file-meta {
    width: 100%;
  }

  .editor-actions {
    width: 100%;
    margin-left: 0;
  }

  .editor-actions .button {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button {
    transition: none;
  }
}
