:root {
  --header-height: 58px;
  --notice-height: 50px;
  --primary: #0067c0;
  --primary-dark: #00529b;
  --header-bg: #111827;
  --header-link: #f9fafb;
  --panel-bg: #ffffff;
  --panel-border: #d8dee8;
  --text-main: #1d2939;
  --text-subtle: #667085;
  --line-soft: #e8ecf2;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  color: var(--text-main);
  font-family: "Noto Sans JP", sans-serif;
  background: #f8f9fb;
}

button, input, select, textarea { font: inherit; }

.app-navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  min-height: var(--header-height);
  background: var(--header-bg);
  border-bottom-color: #111827 !important;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.app-navbar .app-container {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding-inline: 28px;
}

.navbar-brand {
  margin: 0;
  color: var(--header-link);
  font-family: "Anton", sans-serif;
  letter-spacing: 0.05em;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 700;
}

.storage-notice {
  position: sticky;
  top: var(--header-height);
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--notice-height);
  padding: 8px 28px;
  border-bottom: 1px solid #b8d3ee;
  color: #224b70;
  background: #edf6ff;
  font-size: 0.76rem;
}

.storage-notice i { color: var(--primary); }
.storage-notice p { margin: 0; line-height: 1.5; }

.system-message {
  position: fixed;
  z-index: 2000;
  top: calc(var(--header-height) + var(--notice-height) + 12px);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(620px, calc(100% - 28px));
  padding: 12px 14px;
  transform: translateX(-50%);
  border: 1px solid #b8d3ee;
  border-radius: 10px;
  color: #18496f;
  background: #f0f8ff;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.14);
  font-size: 0.86rem;
  font-weight: 700;
}

.system-message.is-error { border-color: #f2b8b5; color: #912018; background: #fff1f0; }
.system-message.is-success { border-color: #a6d9c8; color: #106b4d; background: #effbf6; }
.system-message button { margin-left: auto; border: 0; color: inherit; background: transparent; }

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  height: calc(100dvh - var(--header-height) - var(--notice-height));
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 14px 18px;
  border-right: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(242,246,252,.98));
}

.sidebar-add-button, .category-button, .tool-button, .icon-button { border-radius: 8px; }

.sidebar-add-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 41px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(0,103,192,.55);
  border-radius: 10px;
  color: #005bab;
  background: rgba(0,103,192,.12);
  font-weight: 800;
}

.sidebar-add-button:hover, .sidebar-add-button:focus { color: #004f9e; background: rgba(0,103,192,.18); }

.category-nav { display: grid; gap: 5px; min-height: 0; overflow: auto; padding-right: 2px; }

.category-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid transparent;
  color: #344054;
  text-align: left;
  background: transparent;
}

.category-button:hover, .category-button:focus { border-color: #c9d3e2; background: #fff; outline: none; }
.category-button.is-active { border-color: #9eb4ef; color: var(--primary-dark); background: #eef4ff; box-shadow: inset 3px 0 0 var(--primary); }

.category-main { display: inline-flex; align-items: center; min-width: 0; gap: 9px; font-size: .86rem; font-weight: 800; }
.category-main i { width: 20px; color: var(--primary); text-align: center; }
.category-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 20px; padding: 0 7px; border-radius: 999px; color: #344054; background: #e9edf5; font-size: .72rem; font-weight: 900; }

.main-panel { min-width: 0; min-height: 0; overflow: auto; padding: 0 22px 24px; }
.board-toolbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; min-height: 62px; padding: 16px 0 8px; border-bottom: 1px solid var(--panel-border); background: rgba(248,249,251,.93); backdrop-filter: blur(10px); }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #c9d3e2;
  color: #344054;
  background: #fff;
  font-weight: 800;
}
.tool-button:hover, .tool-button:focus { border-color: #9eb4ef; color: var(--primary-dark); background: #eef4ff; }
.tool-button-primary { min-height: 41px; padding: 10px 14px; border-color: rgba(0,103,192,.55); color: #005bab; background: rgba(0,103,192,.12); }

.mobile-category-row { display: none; }
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; align-items: stretch; padding-top: 12px; }

.link-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: inherit;
  background: var(--panel-bg);
  box-shadow: 0 1px 2px rgba(16,24,40,.05);
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.link-card:hover, .link-card:focus-within { border-color: #a8c7ee; transform: translateY(-1px); box-shadow: 0 8px 18px rgba(22,32,51,.09); }
.link-card[draggable="true"] { cursor: grab; }
.link-card.is-dragging { opacity: .58; transform: scale(.985); }
.link-card.is-drag-over { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,103,192,.18); }

.card-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 2px; }
.icon-button { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; color: #7a8493; background: transparent; }
.icon-button:hover, .icon-button:focus { color: var(--primary-dark); background: #eef4ff; outline: none; }
.favorite-button.is-favorite { color: #e5a000; }
.move-buttons { display: none; }
.card-topline { display: grid; grid-template-columns: 32px minmax(0,1fr); gap: 9px; padding: 3px 64px 0 0; }
.site-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; font-size: 1rem; background: #f2f4f7; }
.accent-multi { color: #4285f4; background: #eef5ff; }
.accent-green { color: #16886a; background: #e5f6ef; }
.accent-blue { color: #2471b9; background: #e7f1fb; }
.accent-red { color: #df2f2f; background: #fff0f0; }
.accent-indigo { color: #4f63d7; background: #eef0ff; }
.accent-slate { color: #1f2937; background: #eef1f5; }
.accent-yellow { color: #d99014; background: #fff6db; }
.accent-amber { color: #b86b00; background: #fff2df; }
.accent-orange { color: #d56520; background: #fff0e8; }
.accent-emerald { color: #13825d; background: #e9f8f1; }
.accent-violet { color: #7146c9; background: #f1ebff; }
.card-title-group { min-width: 0; }
.card-title-group h3 { margin: 0 0 3px; overflow: hidden; color: #1d2939; font-size: .94rem; font-weight: 900; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.card-title-group p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--text-subtle); font-size: .76rem; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.open-link-button { align-self: flex-start; margin: 10px 0 0 41px; padding: 0; border: 0; color: #386c9d; background: transparent; font-size: .72rem; font-weight: 800; }

.empty-state { display: grid; place-items: center; gap: 10px; min-height: 210px; margin-top: 16px; border: 1px dashed #c9d3e2; border-radius: 8px; color: var(--text-subtle); background: #fff; }
.empty-state p { margin: 0; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-field { display: grid; gap: 5px; color: #344054; font-size: .86rem; font-weight: 800; }
.form-field small { color: var(--text-subtle); font-size: .72rem; font-weight: 500; }
.form-field-wide { grid-column: 1 / -1; }
.form-error { margin: 12px 0 0; color: #b42318; font-size: .86rem; font-weight: 800; }

.category-manager { display: grid; gap: 8px; margin-bottom: 16px; }
.category-manager-empty { margin: 0; padding: 16px; border: 1px dashed #c9d3e2; border-radius: 8px; color: var(--text-subtle); text-align: center; }
.category-manager-row { display: grid; grid-template-columns: minmax(160px,1fr) minmax(130px,190px) auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--panel-border); border-radius: 8px; background: #fff; }
.category-manager-actions { display: flex; gap: 6px; }
.category-manager-actions .btn { min-height: 36px; font-weight: 800; }
.category-add-panel { display: grid; grid-template-columns: 1fr 190px; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line-soft); }

.data-help { color: var(--text-subtle); font-size: .86rem; }
.data-action-list { display: grid; gap: 8px; }
.data-action { display: grid; grid-template-columns: 34px 1fr; gap: 10px; width: 100%; padding: 12px; border: 1px solid var(--panel-border); border-radius: 8px; color: var(--text-main); text-align: left; background: #fff; }
.data-action:hover, .data-action:focus { border-color: #9eb4ef; background: #f6f9ff; }
.data-action > i { margin-top: 4px; color: var(--primary); text-align: center; }
.data-action span { display: grid; gap: 2px; }
.data-action small { color: var(--text-subtle); }
.data-action-danger > i { color: #b42318; }
.data-action-warning > i { color: #b86b00; }
.import-summary { display: grid; gap: 7px; padding: 12px; border-radius: 8px; background: #f6f8fb; }
.import-summary div { display: flex; justify-content: space-between; gap: 20px; }
.import-summary dt, .import-summary dd { margin: 0; }
.import-summary dd { font-weight: 900; }
.import-warning { margin: 14px 0 0; color: #8a5300; font-weight: 800; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 72px minmax(0,1fr); }
  .sidebar { padding: 12px 9px; }
  .sidebar-add-button span, .category-main span { display: none; }
  .category-button { justify-content: center; }
  .count-badge { position: absolute; min-width: 19px; height: 17px; padding: 0 5px; transform: translate(16px,-12px); font-size: .62rem; }
  .main-panel { padding-inline: 16px; }
}

@media (max-width: 680px) {
  :root { --notice-height: 83px; }
  .app-navbar .app-container { padding-inline: 14px; }
  .local-badge { font-size: .68rem; }
  .storage-notice { align-items: flex-start; padding: 8px 14px; font-size: .68rem; }
  .storage-notice i { margin-top: 3px; }
  .app-shell { display: block; height: auto; min-height: calc(100dvh - var(--header-height) - var(--notice-height)); overflow: visible; }
  .sidebar { display: none; }
  .main-panel { overflow: visible; padding: 0 14px 22px; }
  .board-toolbar { min-height: 52px; gap: 8px; }
  .toolbar-actions { width: 100%; gap: 7px; }
  .tool-button { flex: 1; min-width: 0; padding: 0 7px; font-size: .76rem; }
  .tool-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-category-row { display: block; padding-top: 12px; }
  .mobile-category-select { width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid #c9d3e2; border-radius: 8px; color: var(--text-main); background: #fff; font-weight: 800; }
  .link-grid { grid-template-columns: 1fr; }
  .link-card { padding-bottom: 44px; }
  .move-buttons { position: absolute; right: 8px; bottom: 7px; display: flex; gap: 4px; }
  .move-buttons .icon-button { border: 1px solid #d8dee8; }
  .form-grid, .category-manager-row, .category-add-panel { grid-template-columns: 1fr; }
  .form-field-wide { grid-column: auto; }
  .system-message { top: calc(var(--header-height) + var(--notice-height) + 8px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
