:root {
  --bg: #f5f6f7;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d7dee6;
  --accent: #216869;
  --accent-dark: #184f50;
  --danger: #b42318;
  --soft: #edf4f3;
  --shadow: 0 16px 36px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--panel);
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.unlock-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #e8f1f2, #f9fafb 58%, #eef3ea);
}

.unlock-panel {
  width: min(100%, 520px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
}

.lead {
  margin: 14px 0 24px;
  color: var(--muted);
  line-height: 1.7;
}

.unlock-form {
  display: grid;
  gap: 14px;
}

.password-line {
  display: flex;
  gap: 8px;
}

.password-line button {
  flex: 0 0 auto;
  padding: 0 12px;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

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

.danger-button {
  border-color: #fecdca;
  color: var(--danger);
}

.message {
  min-height: 22px;
  margin: 12px 0 0;
  color: #9a6700;
  font-weight: 800;
}

.app-shell {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: #17202a;
  color: #fff;
}

.mobile-dock {
  display: none;
}

.brand h1 {
  font-size: 1.42rem;
}

.sidebar .eyebrow {
  color: #9fe0d8;
}

.note-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.note-button {
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 0.86rem;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
}

.note-button.active {
  background: #e9f6f4;
  color: #123334;
}

.sync-panel {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.sync-panel button,
.file-button {
  display: grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.file-button input {
  display: none;
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.search-wrap {
  width: min(100%, 760px);
}

.search-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.search-line button {
  padding: 0 12px;
}

.status {
  display: flex;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.editor {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(260px, 1fr) auto;
  gap: 14px;
  padding: 22px;
  overflow: auto;
}

.title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.title-row input {
  font-size: 1.35rem;
  font-weight: 800;
}

.editor-actions,
.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-actions button,
.table-actions button {
  padding: 0 12px;
}

.format-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.format-toolbar span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.color-button {
  min-height: 32px;
  padding: 0 10px 0 28px;
  position: relative;
  font-size: 0.82rem;
  font-weight: 800;
}

.color-button::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 999px;
  background: var(--swatch);
  transform: translateY(-50%);
}

.note-editor {
  min-height: 0;
  height: 100%;
  overflow: auto;
  font-size: 0.95rem;
  line-height: 1.72;
  white-space: pre-wrap;
  tab-size: 4;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  outline: none;
}

.note-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(33, 104, 105, 0.14);
}

.note-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.search-current {
  border-radius: 3px;
  background: #fff08a;
  box-shadow: 0 0 0 2px #f59e0b;
}

.table-section {
  display: grid;
  gap: 10px;
}

.table-scroll {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

#noteTable {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

#noteTable th,
#noteTable td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0;
  vertical-align: top;
}

#noteTable th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px;
  background: var(--soft);
  text-align: left;
  white-space: nowrap;
}

#noteTable input,
#noteTable textarea {
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#noteTable textarea {
  min-height: 44px;
  resize: vertical;
}

.row-tools {
  display: grid;
  width: 68px;
}

.row-tools button {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  font-size: 0.76rem;
}

.row-tools button + button {
  border-top: 1px solid var(--line);
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    height: 100vh;
    min-height: 0;
    grid-template-columns: 1fr;
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    max-height: 72px;
    min-height: 0;
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 -12px 28px rgba(23, 32, 42, 0.24);
    transition: max-height 0.2s ease;
  }

  .sidebar.open {
    max-height: 78vh;
  }

  .mobile-dock {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 8px;
  }

  .mobile-dock button,
  .mobile-dock input {
    min-height: 42px;
  }

  .mobile-dock button {
    padding: 0 10px;
    white-space: nowrap;
  }

  .mobile-dock input {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
  }

  .mobile-dock input::placeholder {
    color: rgba(255, 255, 255, 0.72);
  }

  .sidebar .brand,
  .sidebar > .primary-button,
  .sidebar .note-list,
  .sidebar .sync-panel {
    display: none;
  }

  .sidebar.open .brand,
  .sidebar.open > .primary-button,
  .sidebar.open .note-list,
  .sidebar.open .sync-panel {
    display: grid;
  }

  .workspace,
  .editor {
    min-height: 0;
  }

  .workspace {
    height: 100vh;
    padding-bottom: 72px;
  }

  .toolbar {
    display: none;
  }

  .editor {
    height: calc(100vh - 72px);
    overflow: auto;
    padding: 14px;
  }

  .title-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .search-line {
    grid-template-columns: 1fr 1fr;
  }

  .search-line input {
    grid-column: 1 / -1;
  }

  .note-editor {
    font-size: 0.86rem;
    line-height: 1.62;
  }
}
