/* ===== 面粗さ・ヘーズ値 共有システム — Fun Theme ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --grad: linear-gradient(120deg, #6366f1 0%, #8b5cf6 45%, #06b6d4 100%);
  --grad-soft: linear-gradient(120deg, #eef2ff, #f5f3ff 45%, #ecfeff);
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --ink: #2b3247;
  --muted: #7a8299;
  --line: #e3e6f0;
  --card: #ffffff;
  --red: #e11d48;
  --red-pale: #ffe4e6;
  --green: #059669;
  --green-pale: #d1fae5;
  --amber-pale: #fef3c7;
  --amber-ink: #92400e;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(99, 102, 241, .08);
  --shadow-hover: 0 10px 24px rgba(99, 102, 241, .18);
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  background:
    radial-gradient(1000px 500px at 110% -10%, rgba(6, 182, 212, .10), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(139, 92, 246, .10), transparent 60%),
    #f5f7fd;
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.6;
  font-size: 14.5px;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

@keyframes floatIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- topbar ---- */
.topbar { background: var(--grad); color: #fff; box-shadow: 0 2px 14px rgba(99,102,241,.35); }
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { color: #fff; font-weight: 700; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  background: #fff; color: var(--primary-dark);
  border-radius: 999px; padding: 2px 12px; margin-right: 8px;
  font-size: 14px; font-weight: 800; letter-spacing: .02em;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.brand-tagline { font-size: 12px; font-weight: 600; opacity: .92; }
.auth-brand {
  text-align: center; font-size: 28px; font-weight: 800; letter-spacing: .02em;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 2px;
}
.userbox { display: flex; align-items: center; gap: 10px; }
.username { font-size: 13.5px; }
.topnav { display: flex; gap: 4px; margin-left: 8px; margin-right: auto; }
.topnav a {
  color: #fff; font-size: 13px; padding: 5px 14px; border-radius: 999px;
  opacity: .9; transition: background .15s, transform .15s;
}
.topnav a:hover { background: rgba(255,255,255,.2); text-decoration: none; opacity: 1; transform: translateY(-1px); }

/* ---- layout ---- */
.container { max-width: 1100px; margin: 26px auto 60px; padding: 0 20px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 0 30px; }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head h1 { font-size: 23px; letter-spacing: .01em; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.project-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; font-size: 13px; }
.project-desc { color: var(--muted); margin-top: 6px; font-size: 13.5px; }

/* ---- cards ---- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; margin-bottom: 22px;
  box-shadow: var(--shadow);
  animation: floatIn .35s ease both;
}
.section-title {
  font-size: 17px; margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, #c7d2fe, #a5f3fc) 1;
}
.target-title {
  font-size: 14.5px; margin: 18px 0 8px; padding: 3px 12px;
  border-left: 4px solid var(--primary);
  background: linear-gradient(90deg, #eef2ff, transparent 70%);
  border-radius: 0 8px 8px 0;
}
.target-title.part {
  border-left-color: #06b6d4;
  background: linear-gradient(90deg, #ecfeff, transparent 70%);
}

/* ---- 会社カラーバッジ ---- */
.company-badge {
  border-radius: 999px; padding: 2px 11px; font-size: 12.5px; font-weight: 700;
  white-space: nowrap; background: #eef2ff; color: #4338ca;
}
.company-badge.sm { font-size: 11.5px; padding: 1px 9px; }
.cb-0 { background: #eef2ff; color: #4338ca; }  /* インディゴ */
.cb-1 { background: #fce7f3; color: #be185d; }  /* ピンク */
.cb-2 { background: #d1fae5; color: #047857; }  /* グリーン */
.cb-3 { background: #fef3c7; color: #b45309; }  /* アンバー */
.cb-4 { background: #cffafe; color: #0e7490; }  /* シアン */
.cb-5 { background: #ede9fe; color: #6d28d9; }  /* バイオレット */
.cb-6 { background: #ffedd5; color: #c2410c; }  /* オレンジ */
.cb-7 { background: #e0f2fe; color: #0369a1; }  /* スカイ */
.topbar .company-badge { box-shadow: 0 2px 6px rgba(0,0,0,.12); }

.chip {
  background: #eef1f7; border-radius: 999px; padding: 2px 11px;
  font-size: 12.5px; color: var(--ink); white-space: nowrap;
}
.chip.sm { font-size: 11px; padding: 1px 9px; color: var(--muted); }
.chip.ref { background: var(--amber-pale); color: var(--amber-ink); }
.mold-no {
  background: var(--amber-pale); color: var(--amber-ink); border-radius: 8px;
  padding: 2px 9px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.spec-bar {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 16px; margin-bottom: 18px; font-size: 13px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  box-shadow: var(--shadow);
}

/* ---- buttons ---- */
.btn {
  display: inline-block; border: none; cursor: pointer; border-radius: 999px;
  padding: 9px 20px; font-size: 14px; font-family: inherit; text-align: center;
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--grad); color: #fff; font-weight: 700;
  box-shadow: 0 4px 14px rgba(99,102,241,.35);
}
.btn-primary:hover { box-shadow: 0 8px 20px rgba(99,102,241,.45); }
.btn-ghost { background: #fff; color: var(--primary-dark); border: 1.5px solid #c7d2fe; }
.btn-ghost:hover { background: #eef2ff; }
.topbar .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.15); }
.btn-danger { background: var(--red-pale); color: var(--red); }
.btn-sm { padding: 4px 14px; font-size: 12.5px; }
.btn-xs { padding: 2px 10px; font-size: 11.5px; }
.btn-block { width: 100%; }

/* ---- flash ---- */
.flash {
  border-radius: 12px; padding: 11px 18px; margin-bottom: 14px; font-size: 13.5px;
  animation: floatIn .3s ease both; font-weight: 600;
}
.flash-success { background: var(--green-pale); color: var(--green); }
.flash-success::before { content: "🎉 "; }
.flash-error { background: var(--red-pale); color: var(--red); }
.flash-error::before { content: "⚠️ "; }

/* ---- auth ---- */
.auth-card {
  max-width: 460px; margin: 40px auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 20px; padding: 36px;
  box-shadow: 0 12px 40px rgba(99,102,241,.15);
  border-top: 5px solid transparent;
  background-clip: padding-box;
  position: relative;
  animation: floatIn .4s ease both;
  text-align: left;
}
.auth-card::before {
  content: ""; position: absolute; top: -5px; left: 20px; right: 20px; height: 5px;
  background: var(--grad); border-radius: 0 0 6px 6px;
}
.auth-emoji { font-size: 44px; text-align: center; margin-bottom: 6px; }
.auth-card h1 { font-size: 22px; margin-bottom: 8px; text-align: center; }
.auth-card form { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.auth-switch { margin-top: 16px; font-size: 12.5px; text-align: center; }

/* ---- forms ---- */
label { display: block; font-size: 13px; font-weight: 700; color: var(--ink); }
input[type="text"], input[type="password"], input[type="number"],
input[type="date"], select, textarea {
  width: 100%; margin-top: 4px; padding: 9px 12px; font-size: 14px;
  font-family: inherit; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.spec-grid { grid-template-columns: repeat(3, 1fr); }
.meas-form { grid-template-columns: repeat(4, 1fr); margin-top: 14px; }
.span2 { grid-column: span 2; }
.form-card { max-width: 760px; }
.form-section-title { font-size: 14px; margin: 22px 0 10px; color: var(--primary-dark); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.req { color: var(--red); font-size: 11px; margin-left: 4px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---- project grid ---- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.project-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; color: var(--ink); display: block;
  border-top: 4px solid var(--primary);
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .2s;
  animation: floatIn .35s ease both;
}
.project-grid .project-card:nth-child(4n+2) { border-top-color: #ec4899; }
.project-grid .project-card:nth-child(4n+3) { border-top-color: #06b6d4; }
.project-grid .project-card:nth-child(4n+4) { border-top-color: #f59e0b; }
.project-card:hover { text-decoration: none; transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.project-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.project-card h2 { font-size: 16px; color: var(--primary-dark); }
.project-material { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.project-card .project-desc {
  font-size: 13px; margin-top: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.project-stats { display: flex; gap: 12px; font-size: 12.5px; color: var(--primary-dark); margin-top: 12px; flex-wrap: wrap; }
.project-meta { font-size: 11.5px; color: var(--muted); margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.empty-state {
  background: var(--card); border: 2px dashed #c7d2fe; border-radius: var(--radius);
  text-align: center; padding: 50px 20px; color: var(--muted);
  animation: floatIn .35s ease both;
}
.empty-emoji { font-size: 46px; margin-bottom: 10px; }

/* ---- data table ---- */
.table-wrap { overflow-x: auto; border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  background: linear-gradient(90deg, #eef2ff, #ecfeff);
  color: var(--primary-dark); text-align: left;
  padding: 9px 10px; font-size: 12.5px; white-space: nowrap;
}
.data-table th:first-child { border-radius: 10px 0 0 10px; }
.data-table th:last-child { border-radius: 0 10px 10px 0; }
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:hover td { background: #f6f8ff; }
.val { font-variant-numeric: tabular-nums; font-weight: 700; }
.val.ng { color: var(--red); }
.val.ok { color: var(--green); }
.ng-mark {
  background: var(--red); color: #fff; border-radius: 6px;
  padding: 0 6px; font-size: 10.5px; font-weight: 800; vertical-align: 1px;
}
.ok-mark {
  background: var(--green-pale); color: var(--green); border-radius: 999px;
  padding: 0 5px; font-size: 11px; font-weight: 800; vertical-align: 1px;
}
.note-cell { max-width: 220px; font-size: 12.5px; color: var(--muted); }
.attach-cell { white-space: nowrap; }
.attach-link { display: inline-block; margin-right: 2px; transition: transform .15s; }
.attach-link:hover { text-decoration: none; transform: scale(1.15); }
.page-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-form { display: flex; gap: 8px; align-items: center; }
.search-form input[type="text"] { width: 320px; margin-top: 0; }
.who-cell { white-space: nowrap; font-size: 12.5px; }
.center { text-align: center; }
.muted { color: var(--muted); font-weight: 400; }

.add-form { margin-top: 18px; }
.add-form summary { list-style: none; width: fit-content; }
.add-form summary::-webkit-details-marker { display: none; }
.add-form[open] summary { margin-bottom: 4px; }

/* ---- files ---- */
.file-list { list-style: none; }
.file-list li {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 8px; border-bottom: 1px solid var(--line);
  border-radius: 10px;
  transition: background .15s;
}
.file-list li:hover { background: #f6f8ff; }
.file-icon {
  display: inline-block; min-width: 44px; text-align: center;
  border-radius: 8px; padding: 3px 7px; font-size: 11px; font-weight: 800;
  background: #e8ebf3; color: #4a5568;
}
.file-icon.sm { min-width: 38px; font-size: 10px; padding: 2px 6px; }
.file-icon.pdf { background: #ffe4e6; color: #be123c; }
.file-icon.xls { background: #d1fae5; color: #047857; }
.file-icon.doc { background: #dbeafe; color: #1d4ed8; }
.file-icon.ppt { background: #ffedd5; color: #c2410c; }
.file-icon.img { background: #ede9fe; color: #7c3aed; }
.file-name { font-weight: 700; }
.file-meta { font-size: 12px; color: var(--muted); }
.upload-form { display: flex; gap: 10px; margin-top: 16px; align-items: center; flex-wrap: wrap; }
.upload-form input[type="file"] { flex: 1; min-width: 240px; margin-top: 0; }
.upload-form select { width: auto; min-width: 200px; margin-top: 0; }
.ref-upload-form { margin-top: 8px; }
.ref-fields { width: 100%; display: flex; gap: 10px; flex-wrap: wrap; }
.ref-fields input[type="text"] { flex: 1; min-width: 220px; margin-top: 0; }
.ref-filename { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.ref-filename.inline { display: inline; margin-left: 4px; }
.ref-note { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.inline-form { display: inline; }
.chat-box { max-height: 60vh; overflow-y: auto; padding-right: 6px; }
.file-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.row-actions { white-space: nowrap; }
.row-actions form { display: inline; }
.check-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.check-label input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
input[type="file"] {
  font-size: 13px; padding: 8px; border: 2px dashed #c7d2fe;
  border-radius: 12px; background: #fafbff; width: 100%;
  transition: border-color .15s, background .15s;
}
input[type="file"]:hover { border-color: var(--primary); background: #f3f5ff; }

/* ---- comments ---- */
.comment-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 18px; }
.thread { display: flex; flex-direction: column; gap: 8px; }
.comment.reply {
  margin-left: 36px; position: relative;
  border-radius: 4px 14px 14px 14px;
  padding: 10px 15px; font-size: 13.5px;
}
.comment.reply::before {
  content: ""; position: absolute; left: -20px; top: -6px;
  width: 14px; height: 22px;
  border-left: 2px solid #c7d2fe; border-bottom: 2px solid #c7d2fe;
  border-radius: 0 0 0 10px;
}
.reply-toggle {
  background: none; border: none; cursor: pointer; font-family: inherit;
  color: var(--primary-dark); font-size: 12px; font-weight: 700;
  padding: 2px 0 0; margin-top: 4px; display: inline-block;
}
.reply-toggle:hover { text-decoration: underline; }
.reply-form { margin-left: 36px; }
.reply-form textarea { margin-top: 0; }
.comment {
  border: 1px solid var(--line); border-radius: 16px 16px 16px 4px;
  padding: 13px 18px; background: #fafbff;
  animation: floatIn .3s ease both;
}
.comment.mine {
  background: linear-gradient(120deg, #eef2ff, #ecfeff);
  border-color: #c7d2fe; border-radius: 16px 16px 4px 16px;
}
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 4px; flex-wrap: wrap; }
.comment-body { white-space: pre-wrap; font-size: 14px; }
.comment-files { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.comment-file { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.comment-form textarea { margin-top: 0; }
.comment-form-actions { display: flex; gap: 10px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.comment-form-actions input[type="file"] { flex: 1; min-width: 240px; margin-top: 0; }

/* ---- responsive ---- */
@media (max-width: 720px) {
  .form-grid, .spec-grid, .meas-form { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .page-head { flex-direction: column; }
  .topnav { order: 3; width: 100%; justify-content: center; margin: 4px 0 0; }
  .topbar-inner { flex-wrap: wrap; }
}
